diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-25 02:52:40 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-25 02:52:40 +0300 |
commit | b40ccf4a4d1391ba1f67a159697fea859e2a92fd (patch) | |
tree | 44d9638a98db6513ff450ab2839e993c3613c03b /xmpp | |
parent | 4532748c8458971151dfb6b535b11b2a3e17a372 (diff) |
Fix presences sent with no resource
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/gateway/gateway.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index dfe2ebf..981858d 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -3,6 +3,7 @@ package gateway import ( "encoding/xml" "github.com/pkg/errors" + "strconv" "strings" "sync" @@ -343,6 +344,20 @@ func SendPresence(component *xmpp.Component, to string, args ...args.V) error { return nil } +// SPAppendFrom appends numeric from and resource to varargs +func SPAppendFrom(oldArgs []args.V, id int64) []args.V { + newArgs := append(oldArgs, SPFrom(strconv.FormatInt(id, 10))) + newArgs = append(newArgs, SPResource(Jid.Resource)) + return newArgs +} + +// SimplePresence crafts simple presence varargs +func SimplePresence(from int64, typ string) []args.V { + args := []args.V{SPType(typ)} + args = SPAppendFrom(args, from) + return args +} + // ResumableSend tries to resume the connection once and sends the packet again func ResumableSend(component *xmpp.Component, packet stanza.Packet) error { err := component.Send(packet) |