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 {