diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-08 20:09:14 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-08 20:09:14 +0300 |
commit | 76364388ad2d7baa0718dff50902eacd4c090edf (patch) | |
tree | 02d88879b2f5534a5b66e79ce6247a1502589d16 /xmpp | |
parent | 32036e3f90fc1c41df430d9d811fa3d04844b349 (diff) |
Add disco query responder
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/handlers.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 0f4b949..d14fd31 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -35,6 +35,12 @@ func HandleIq(s xmpp.Sender, p stanza.Packet) { _, ok := iq.Payload.(*extensions.IqVcardTemp) if ok { go handleGetVcardTempIq(s, iq) + return + } + _, ok = iq.Payload.(*stanza.DiscoInfo) + if ok { + go handleGetDiscoInfo(s, iq) + return } } } @@ -295,6 +301,33 @@ func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) { _ = gateway.ResumableSend(component, &answer) } +func handleGetDiscoInfo(s xmpp.Sender, iq *stanza.IQ) { + answer, err := stanza.NewIQ(stanza.Attrs{ + Type: stanza.IQTypeResult, + From: iq.To, + To: iq.From, + Id: iq.Id, + Lang: "en", + }) + if err != nil { + log.Errorf("Failed to create answer IQ: %v", err) + } + + disco := answer.DiscoInfo() + disco.AddIdentity("Telegram Gateway", "gateway", "telegram") + answer.Payload = disco + + log.Debugf("%#v", answer) + + component, ok := s.(*xmpp.Component) + if !ok { + log.Error("Not a component") + return + } + + _ = gateway.ResumableSend(component, answer) +} + func splitFrom(from string) (string, string, bool) { fromJid, err := stanza.NewJid(from) if err != nil { |