aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-26 16:51:15 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-26 16:51:15 +0100
commitd97a76fcc338e7a532d0796ce5b12bdefb0a6f17 (patch)
treef8237e03007293bf4215348cd8452d65c69d5b0d /connector
parentfacc375e8cf41f87f6b90fe5117754e2b639ce83 (diff)
downloadeasybridge-d97a76fcc338e7a532d0796ce5b12bdefb0a6f17.tar.gz
easybridge-d97a76fcc338e7a532d0796ce5b12bdefb0a6f17.zip
Handle event IDs on xmpp; do not echo back messages
Diffstat (limited to 'connector')
-rw-r--r--connector/xmpp/xmpp.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go
index 1215a66..0573ddb 100644
--- a/connector/xmpp/xmpp.go
+++ b/connector/xmpp/xmpp.go
@@ -7,7 +7,8 @@ import (
"fmt"
"strings"
- gxmpp "github.com/mattn/go-xmpp"
+ gxmpp "github.com/matterbridge/go-xmpp"
+ "github.com/rs/xid"
log "github.com/sirupsen/logrus"
. "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
@@ -225,6 +226,7 @@ func (xm *XMPP) handleXMPP() error {
if v.Type == "groupchat" && len(remote_sp) == 2 {
event.Room = RoomID(remote_sp[0])
event.Author = UserID(remote_sp[1] + "@" + remote_sp[0])
+ event.Id = v.ID
xm.handler.Event(event)
}
}
@@ -331,10 +333,14 @@ func (xm *XMPP) Send(event *Event) error {
})
return err
} else if len(event.Room) > 0 {
+ if event.Id == "" {
+ event.Id = xid.New().String()
+ }
_, err := xm.conn.Send(gxmpp.Chat{
Type: "groupchat",
Remote: string(event.Room),
Text: event.Text,
+ ID: event.Id,
})
return err
} else {