aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2024-05-12 18:03:48 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2024-05-12 18:03:48 +0300
commite94a646e19b3bca5be4e97b6d756d257034a5788 (patch)
tree019db5e9f0c87303f4807cbb2471b8cfc66f1dfb /xmpp
parent249c942fc2d9f017ffb66c98f22e7f2a2c40ad2a (diff)
Upgrade to go-xmpp version with multiple command elements support
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/handlers.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 1a47c10..2615290 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -749,13 +749,20 @@ func handleSetQueryCommand(s xmpp.Sender, iq *stanza.IQ, command *stanza.Command
var cmdString string
var cmdType telegram.CommandType
- form, formOk := command.CommandElement.(*stanza.Form)
+ var form *stanza.Form
+ for _, ce := range command.CommandElements {
+ fo, formOk := ce.(*stanza.Form)
+ if formOk {
+ form = fo
+ break
+ }
+ }
if toOk {
cmdType = telegram.CommandTypeChat
} else {
cmdType = telegram.CommandTypeTransport
}
- if formOk {
+ if form != nil {
// just for the case the client messed the order somehow
sort.Slice(form.Fields, func(i int, j int) bool {
iField := form.Fields[i]
@@ -844,10 +851,10 @@ func handleSetQueryCommand(s xmpp.Sender, iq *stanza.IQ, command *stanza.Command
Fields: fields,
}
answer.Payload = &stanza.Command{
- SessionId: command.Node,
- Node: command.Node,
- Status: stanza.CommandStatusExecuting,
- CommandElement: &form,
+ SessionId: command.Node,
+ Node: command.Node,
+ Status: stanza.CommandStatusExecuting,
+ CommandElements: []stanza.CommandElement{&form},
}
log.Debugf("form: %#v", form)
} else {
@@ -884,12 +891,14 @@ func handleSetQueryCommand(s xmpp.Sender, iq *stanza.IQ, command *stanza.Command
}
answer.Payload = &stanza.Command{
- SessionId: command.Node,
- Node: command.Node,
- Status: stanza.CommandStatusCompleted,
- CommandElement: &stanza.Note{
- Text: response,
- Type: noteType,
+ SessionId: command.Node,
+ Node: command.Node,
+ Status: stanza.CommandStatusCompleted,
+ CommandElements: []stanza.CommandElement{
+ &stanza.Note{
+ Text: response,
+ Type: noteType,
+ },
},
}