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/slack/slack.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/slack/slack.go')
-rw-r--r-- | bridge/slack/slack.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index c7205464..fa847db9 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -166,6 +166,16 @@ func (b *Bslack) Send(msg config.Message) (string, error) { // replace mentions np.LinkNames = 1 + if msg.Event == config.EVENT_MSG_DELETE { + // some protocols echo deletes, but with empty ID + if msg.ID == "" { + return "", nil + } + // we get a "slack <ID>", split it + ts := strings.Fields(msg.ID) + b.sc.DeleteMessage(schannel.ID, ts[1]) + return "", nil + } // if we have no ID it means we're creating a new message, not updating an existing one if msg.ID != "" { ts := strings.Fields(msg.ID) @@ -231,7 +241,7 @@ func (b *Bslack) handleSlack() { if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" && message.Username == b.si.User.Name { continue } - if message.Text == "" || message.Username == "" { + if (message.Text == "" || message.Username == "") && message.Raw.SubType != "message_deleted" { continue } text := message.Text @@ -250,6 +260,12 @@ func (b *Bslack) handleSlack() { if message.Raw.SubMessage != nil { msg.ID = "slack " + message.Raw.SubMessage.Timestamp } + if message.Raw.SubType == "message_deleted" { + msg.Text = config.EVENT_MSG_DELETE + msg.Event = config.EVENT_MSG_DELETE + msg.ID = "slack " + message.Raw.DeletedTimestamp + } + flog.Debugf("Message is %#v", msg) b.Remote <- msg } } @@ -276,7 +292,7 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) { continue } m := &MMMessage{} - if ev.BotID == "" { + if ev.BotID == "" && ev.SubType != "message_deleted" { user, err := b.rtm.GetUserInfo(ev.User) if err != nil { continue |