diff options
author | Wim <wim@42.be> | 2017-09-11 22:45:15 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-09-11 22:45:15 +0200 |
commit | ed018207226912ee57ecaae06c539aea37e7bb96 (patch) | |
tree | 4426d2bfd3041c9110b9b2e4ad38c35e9e918bff /bridge/mattermost/mattermost.go | |
parent | 90a61f15cc93ddca78f598dc6856c759a91bd96a (diff) | |
download | matterbridge-msglm-ed018207226912ee57ecaae06c539aea37e7bb96.tar.gz matterbridge-msglm-ed018207226912ee57ecaae06c539aea37e7bb96.tar.bz2 matterbridge-msglm-ed018207226912ee57ecaae06c539aea37e7bb96.zip |
Add support for deleting messages across bridges.
Currently fully support mattermost,slack and discord.
Message deleted on the bridge or received from other bridges will be
deleted.
Partially support for Gitter.
Gitter bridge will delete messages received from other bridges.
But if you delete a message on gitter, this deletion will not be sent to
other bridges (this is a gitter API limitation, it doesn't propogate edits
or deletes via the API)
Diffstat (limited to 'bridge/mattermost/mattermost.go')
-rw-r--r-- | bridge/mattermost/mattermost.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 30e38042..6e5b3d38 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -25,6 +25,7 @@ type MMMessage struct { Username string UserID string ID string + Event string } type Bmattermost struct { @@ -168,6 +169,12 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) { } return "", nil } + if msg.Event == config.EVENT_MSG_DELETE { + if msg.ID == "" { + return "", nil + } + return msg.ID, b.mc.DeleteMessage(msg.ID) + } if msg.ID != "" { return b.mc.EditMessage(msg.ID, message) } @@ -188,7 +195,7 @@ func (b *Bmattermost) handleMatter() { go b.handleMatterClient(mchan) } for message := range mchan { - rmsg := config.Message{Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID, ID: message.ID} + rmsg := config.Message{Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID, ID: message.ID, Event: message.Event} text, ok := b.replaceAction(message.Text) if ok { rmsg.Event = config.EVENT_USER_ACTION @@ -215,7 +222,7 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { } // do not post our own messages back to irc // only listen to message from our team - if (message.Raw.Event == "posted" || message.Raw.Event == "post_edited") && + if (message.Raw.Event == "posted" || message.Raw.Event == "post_edited" || message.Raw.Event == "post_deleted") && b.mc.User.Username != message.Username && message.Raw.Data["team_id"].(string) == b.TeamId { // if the message has reactions don't repost it (for now, until we can correlate reaction with message) if message.Post.HasReactions { @@ -231,6 +238,9 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { if message.Raw.Event == "post_edited" && !b.Config.EditDisable { m.Text = message.Text + b.Config.EditSuffix } + if message.Raw.Event == "post_deleted" { + m.Event = config.EVENT_MSG_DELETE + } if len(message.Post.FileIds) > 0 { for _, link := range b.mc.GetFileLinks(message.Post.FileIds) { m.Text = m.Text + "\n" + link |