diff --git a/messages/go.mod b/messages/go.mod new file mode 100644 index 0000000..7be10f6 --- /dev/null +++ b/messages/go.mod @@ -0,0 +1,12 @@ +module dev.sum7.eu/genofire/unified-push-xmpp/messages + +go 1.17 + +require mellium.im/xmpp v0.19.0 + +require ( + golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect + golang.org/x/text v0.3.2 // indirect + mellium.im/reader v0.1.0 // indirect + mellium.im/xmlstream v0.15.3-0.20210221202126-7cc1407dad4c // indirect +) diff --git a/messages/go.sum b/messages/go.sum new file mode 100644 index 0000000..f4975d3 --- /dev/null +++ b/messages/go.sum @@ -0,0 +1,21 @@ +golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +mellium.im/reader v0.1.0 h1:UUEMev16gdvaxxZC7fC08j7IzuDKh310nB6BlwnxTww= +mellium.im/reader v0.1.0/go.mod h1:F+X5HXpkIfJ9EE1zHQG9lM/hO946iYAmU7xjg5dsQHI= +mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= +mellium.im/xmlstream v0.15.3-0.20210221202126-7cc1407dad4c h1:1RCzOXu94kvNjuCC89G+5XTP6GOdoDrLsYdGIryyc2Y= +mellium.im/xmlstream v0.15.3-0.20210221202126-7cc1407dad4c/go.mod h1:7SUlP7f2qnMczK+Cu/OFgqaIhldMolVjo8np7xG41D0= +mellium.im/xmpp v0.19.0 h1:zgW0jOOxEfQn8v+zUsInaZikSa8BELpKpvnTYzM435E= +mellium.im/xmpp v0.19.0/go.mod h1:zpU69WRb0YuYcVTM/GVweZQP8r48nj1Tlq8RLXUOSNE= diff --git a/messages/main.go b/messages/main.go new file mode 100644 index 0000000..32223b0 --- /dev/null +++ b/messages/main.go @@ -0,0 +1,62 @@ +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 + Register +} + +// Register without stanza +type Register struct { + XMLName xml.Name `xml:"unifiedpush.org register"` + // set + Token string `xml:"token,omitempty"` + // result + Endpoint string `xml:"endpoint,omitempty"` + // error + Error string `xml:"error,omitempty"` +} + +// UnregisterIQ with stanza +type UnregisterIQ struct { + stanza.IQ + Unregister +} + +// Unregister without stanza +type Unregister struct { + XMLName xml.Name `xml:"unifiedpush.org unregister"` + // set + 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 + Token string `xml:"subject"` + Body string `xml:"body"` +} + +// MessageBody of push notification - without stanza +type MessageBody struct { + Token string `xml:"subject"` + Body string `xml:"body"` +}