diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-03-08 15:51:19 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-03-08 15:51:19 +0300 |
commit | b1135b070b751998cb98eded6d29bdd7b800ecb9 (patch) | |
tree | 7063960016850ca04587ac5a94e60f59f676de88 /xmpp/extensions/extensions.go | |
parent | 4a5b83dff5c568871d5624202e2ee27e5d0de242 (diff) |
Cut fallback quotes out
Diffstat (limited to 'xmpp/extensions/extensions.go')
-rw-r--r-- | xmpp/extensions/extensions.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go index ce27656..7e44bae 100644 --- a/xmpp/extensions/extensions.go +++ b/xmpp/extensions/extensions.go @@ -2,6 +2,7 @@ package extensions import ( "encoding/xml" + "strconv" "gosrc.io/xmpp/stanza" ) @@ -118,6 +119,28 @@ type Reply struct { Id string `xml:"id,attr"` } +// Fallback is from XEP-0428 +type Fallback struct { + XMLName xml.Name `xml:"urn:xmpp:fallback:0 fallback"` + For string `xml:"for,attr"` + Body []FallbackBody + Subject []FallbackSubject +} + +// FallbackBody is from XEP-0428 +type FallbackBody struct { + XMLName xml.Name `xml:"body"` + Start string `xml:"start,attr"` + End string `xml:"end,attr"` +} + +// FallbackSubject is from XEP-0428 +type FallbackSubject struct { + XMLName xml.Name `xml:"subject"` + Start string `xml:"start,attr"` + End string `xml:"end,attr"` +} + // Namespace is a namespace! func (c PresenceNickExtension) Namespace() string { return c.XMLName.Space @@ -143,6 +166,24 @@ func (c Reply) Namespace() string { return c.XMLName.Space } +// Namespace is a namespace! +func (c Fallback) Namespace() string { + return c.XMLName.Space +} + +// NewReplyFallback initializes a fallback range +func NewReplyFallback(start uint64, end uint64) Fallback { + return Fallback{ + For: "urn:xmpp:reply:0", + Body: []FallbackBody{ + FallbackBody{ + Start: strconv.FormatUint(start, 10), + End: strconv.FormatUint(end, 10), + }, + }, + } +} + func init() { // presence nick stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{ @@ -167,4 +208,10 @@ func init() { "urn:xmpp:reply:0", "reply", }, Reply{}) + + // fallback + stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{ + "urn:xmpp:fallback:0", + "fallback", + }, Fallback{}) } |