From d97a76fcc338e7a532d0796ce5b12bdefb0a6f17 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 26 Feb 2020 16:51:15 +0100 Subject: Handle event IDs on xmpp; do not echo back messages --- connector/xmpp/xmpp.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'connector') 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 { -- cgit v1.2.3