2021-09-11 00:49:23 +02:00
|
|
|
package messages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
|
|
|
|
"mellium.im/xmpp/stanza"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Namespace
|
|
|
|
const (
|
|
|
|
Space = "unifiedpush.org"
|
|
|
|
|
|
|
|
LocalRegister = "register"
|
|
|
|
LocalUnregister = "unregister"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RegisterIQ with stanza
|
|
|
|
type RegisterIQ struct {
|
|
|
|
stanza.IQ
|
2021-09-12 00:31:03 +02:00
|
|
|
Register struct {
|
|
|
|
XMLName xml.Name `xml:"unifiedpush.org register"`
|
|
|
|
Token *TokenData `xml:"token"`
|
2021-09-11 17:16:38 +02:00
|
|
|
Endpoint *EndpointData `xml:"endpoint"`
|
2021-09-12 00:31:03 +02:00
|
|
|
Error *ErrorData `xml:"error"`
|
2021-09-11 17:16:38 +02:00
|
|
|
} `xml:"register"`
|
2021-09-11 00:49:23 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 21:55:21 +02:00
|
|
|
// TokenData transport the public token from distributor to gateway
|
2021-09-11 17:16:38 +02:00
|
|
|
type TokenData struct {
|
|
|
|
XMLName xml.Name `xml:"token"`
|
2021-09-12 00:31:03 +02:00
|
|
|
Body string `xml:",chardata"`
|
2021-09-11 17:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type EndpointData struct {
|
|
|
|
XMLName xml.Name `xml:"endpoint"`
|
2021-09-12 00:31:03 +02:00
|
|
|
Body string `xml:",chardata"`
|
2021-09-11 17:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type ErrorData struct {
|
|
|
|
XMLName xml.Name `xml:"error"`
|
2021-09-12 00:31:03 +02:00
|
|
|
Body string `xml:",chardata"`
|
2021-09-11 00:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnregisterIQ with stanza
|
|
|
|
type UnregisterIQ struct {
|
|
|
|
stanza.IQ
|
|
|
|
Unregister
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unregister without stanza
|
|
|
|
type Unregister struct {
|
|
|
|
XMLName xml.Name `xml:"unifiedpush.org unregister"`
|
2021-09-14 21:55:21 +02:00
|
|
|
// set - public token
|
2021-09-11 00:49:23 +02:00
|
|
|
Token string `xml:"token,omitempty"`
|
|
|
|
// result
|
|
|
|
Success *string `xml:"success,omitempty"`
|
|
|
|
// error
|
|
|
|
Error string `xml:"error,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Message of push notification - with stanza
|
|
|
|
type Message struct {
|
|
|
|
stanza.Message
|
2021-09-14 21:55:21 +02:00
|
|
|
PublicToken string `xml:"subject"`
|
|
|
|
Body string `xml:"body"`
|
2021-09-11 00:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// MessageBody of push notification - without stanza
|
|
|
|
type MessageBody struct {
|
2021-09-14 21:55:21 +02:00
|
|
|
PublicToken string `xml:"subject"`
|
|
|
|
Body string `xml:"body"`
|
2021-09-11 00:49:23 +02:00
|
|
|
}
|