diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-29 10:01:42 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-29 10:01:42 +0100 |
commit | 38a3f1bdb18159cc4808fa86280da55f0599dcc8 (patch) | |
tree | 9976cd829d5fc3953d382dcc955a7b270f2ab728 /connector/irc | |
parent | 1c038995be9f869be1b69a604e42096807806676 (diff) | |
download | easybridge-38a3f1bdb18159cc4808fa86280da55f0599dcc8.tar.gz easybridge-38a3f1bdb18159cc4808fa86280da55f0599dcc8.zip |
Fix Mattermost event deduplication
Mattermost assigns its own IDs to messages, thus when sending a message
to Mattermost the event_seen key that has to be written must take into
account that ID and not the one that we put in the event (which was the
Matrix event ID)
Note that for XMPP anything can be used as an ID, so using the Matrix
event ID there worked, but it's actually not so good.
Diffstat (limited to 'connector/irc')
-rw-r--r-- | connector/irc/irc.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/connector/irc/irc.go b/connector/irc/irc.go index dafe9db..4e5f4fd 100644 --- a/connector/irc/irc.go +++ b/connector/irc/irc.go @@ -198,9 +198,9 @@ func (irc *IRC) Leave(roomId RoomID) { irc.conn.Cmd.Part(ch) } -func (irc *IRC) Send(event *Event) error { +func (irc *IRC) Send(event *Event) (string, error) { if irc.conn == nil { - return fmt.Errorf("Not connected") + return "", fmt.Errorf("Not connected") } // Workaround girc bug @@ -212,17 +212,17 @@ func (irc *IRC) Send(event *Event) error { if event.Room != "" { ch, err := irc.checkRoomId(event.Room) if err != nil { - return err + return "", err } dest = ch } else if event.Recipient != "" { ui, err := irc.checkUserId(event.Recipient) if err != nil { - return err + return "", err } dest = ui } else { - return fmt.Errorf("Invalid target") + return "", fmt.Errorf("Invalid target") } if event.Attachments != nil && len(event.Attachments) > 0 { @@ -230,7 +230,7 @@ func (irc *IRC) Send(event *Event) error { url := at.URL() if url == "" { // TODO find a way to send them using some hosing of some kind - return fmt.Errorf("Attachment without URL sent to IRC") + return "", fmt.Errorf("Attachment without URL sent to IRC") } else { irc.conn.Cmd.Message(dest, fmt.Sprintf("%s (%s, %dkb)", url, at.Mimetype(), at.Size()/1024)) @@ -243,9 +243,9 @@ func (irc *IRC) Send(event *Event) error { } else if event.Type == EVENT_ACTION { irc.conn.Cmd.Action(dest, event.Text) } else { - return fmt.Errorf("Invalid event type") + return "", fmt.Errorf("Invalid event type") } - return nil + return "", nil } func (irc *IRC) Close() { |