Add disco query responder
This commit is contained in:
parent
32036e3f90
commit
76364388ad
|
@ -35,6 +35,12 @@ func HandleIq(s xmpp.Sender, p stanza.Packet) {
|
||||||
_, ok := iq.Payload.(*extensions.IqVcardTemp)
|
_, ok := iq.Payload.(*extensions.IqVcardTemp)
|
||||||
if ok {
|
if ok {
|
||||||
go handleGetVcardTempIq(s, iq)
|
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)
|
_ = 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) {
|
func splitFrom(from string) (string, string, bool) {
|
||||||
fromJid, err := stanza.NewJid(from)
|
fromJid, err := stanza.NewJid(from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue