Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack -> Discord Deleting message with an image does not work. #1705

Closed
noisymime opened this issue Feb 2, 2022 · 0 comments
Closed

Slack -> Discord Deleting message with an image does not work. #1705

noisymime opened this issue Feb 2, 2022 · 0 comments

Comments

@noisymime
Copy link

Describe the bug
A message created in Slack is bridged through to Discord OK. Deleting that message in Slack will delete the msg in Discord, however not when the original message contains an image.

To Reproduce

  • Send a message in Slack that contains an image
  • Confirm msg and image appear in Discord
  • Delete msg in Slack
  • Msg is not deleted in Discord

Expected behavior
Messages containing images should be deleted, just like messages containing no images.

Screenshots/debug logs
Debug log when deleting a message containing an image.

[0235] DEBUG slack:        [handleSlackClient:bridge/slack/handlers.go:52] == Receiving event &slack.MessageEvent{Msg:slack.Msg{ClientMsgID:"", Type:"message", Channel:"C09MSS9U1", User:"", Text:"", Timestamp:"1643760897.164700", ThreadTimestamp:"", IsStarred:false, PinnedTo:[]string(nil), Attachments:[]slack.Attachment(nil), Edited:(*slack.Edited)(nil), LastRead:"", Subscribed:false, UnreadCount:0, SubType:"message_deleted", Hidden:true, DeletedTimestamp:"1643760888.862179", EventTimestamp:"1643760897.164700", BotID:"", Username:"", Icons:(*slack.Icon)(nil), BotProfile:(*slack.BotProfile)(nil), Inviter:"", Topic:"", Purpose:"", Name:"", OldName:"", Members:[]string(nil), ReplyCount:0, Replies:[]slack.Reply(nil), ParentUserId:"", Files:[]slack.File(nil), Upload:false, Comment:(*slack.Comment)(nil), ItemType:"", ReplyTo:0, Team:"", Reactions:[]slack.ItemReaction(nil), ResponseType:"", ReplaceOriginal:false, DeleteOriginal:false, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}}, SubMessage:(*slack.Msg)(nil), PreviousMessage:(*slack.Msg)(0xc00026f680)}
[0235] DEBUG slack:        [handleSlack:bridge/slack/handlers.go:44] <= Message is &config.Message{Text:"msg_delete", Channel:"general", Username:"", UserID:"", Avatar:"", Account:"slack.speeduino", Event:"msg_delete", Protocol:"slack", Gateway:"", ParentID:"", Timestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ID:"1643760888.862179", Extra:map[string][]interface {}{}}
[0235] DEBUG gateway:      [SendMessage:gateway/gateway.go:479] => Sending config.Message{Text:"msg_delete", Channel:"general", Username:"", UserID:"", Avatar:"", Account:"slack.speeduino", Event:"msg_delete", Protocol:"slack", Gateway:"gateway_main", ParentID:"", Timestamp:time.Date(2022, time.February, 2, 0, 14, 57, 982287616, time.Local), ID:"1643760888.862179", Extra:map[string][]interface {}{}} from slack.speeduino (general) to discord.speeduino (general)
[0235] DEBUG discord:      [Send:bridge/discord/discord.go:235] => Receiving config.Message{Text:"msg_delete", Channel:"general", Username:" (Slack)", UserID:"", Avatar:"", Account:"slack.speeduino", Event:"msg_delete", Protocol:"slack", Gateway:"gateway_main", ParentID:"", Timestamp:time.Date(2022, time.February, 2, 0, 14, 57, 982287616, time.Local), ID:"", Extra:map[string][]interface {}{}}

One thing I've noted is that on the final line there is ID:"". When performing a deletion on a message that does not contain an image, this ID value contains the msg ID, however this appears to be missing when the original msg contains an image.

Environment (please complete the following information):

  • OS: linux (Docker image)
  • Matterbridge version: 1.23.2 73ec02a

Additional context
Config:

[discord]
[discord.speeduino]
Token="XXXX"

# Server (REQUIRED) is the ID or name of the guild to connect to, selected from the guilds the bot has been invited to
Server="Speeduino"
AutoWebhooks=true
RemoteNickFormat="{NICK} (Slack)"
PreserveThreading=true

[slack]
[slack.speeduino]
Token="XXXX"
RemoteNickFormat="{NICK} (Discord)"
PreserveThreading=true

[[gateway]]
name="gateway_main"
enable=true

[[gateway.inout]]
account="discord.speeduino"
channel="general"

[[gateway.inout]]
account="slack.speeduino"
channel="general"

[[samechannelgateway]]
   name="samechannel"
   enable = true
   accounts = [ "discord.speeduino","slack.speeduino" ]
   channels = [ "git","development","hardware","help","random","simulators","theory","yourprojects","wiki"]
@noisymime noisymime added the bug label Feb 2, 2022
@noisymime noisymime changed the title Slick->Discord Deleting message with an image does not work. Slack -> Discord Deleting message with an image does not work. Feb 2, 2022
@42wim 42wim added the slack label Feb 4, 2022
42wim added a commit that referenced this issue Feb 4, 2022
We create a new event EventFileDelete which will be used to delete
specific uploaded files using the Extra["file"] in the config.Message.

We also add a new NativeID key to the FileInfo struct which will contain
the native file ID of the sending bridge.

When a new file is added to the config.Message.Extra["file"] map, now
the bridge native file ID should be added here.

When the receiving bridge receives such a message, it should keep an
internal mapping of NativeID <> bridge fileid/message id. In the case of
discord we map it to the resulted discord message ID after uploading it.

Now when a bridge deletes a file, it should send a EventFileDelete and
setting the ID to the native file ID of the bridge.

When the receiving bridge will get this event it'll look into the
NativeID <> bridge id mapping to find their internal ID and use it to
delete the specific file on their side.

For now this is implemented for slack to discord but this will be add to
other bridges where useful.
42wim added a commit that referenced this issue Feb 4, 2022
We create a new event EventFileDelete which will be used to delete
specific uploaded files using the Extra["file"] in the config.Message.

We also add a new NativeID key to the FileInfo struct which will contain
the native file ID of the sending bridge.

When a new file is added to the config.Message.Extra["file"] map, now
the bridge native file ID should be added here.

When the receiving bridge receives such a message, it should keep an
internal mapping of NativeID <> bridge fileid/message id. In the case of
discord we map it to the resulted discord message ID after uploading it.

Now when a bridge deletes a file, it should send a EventFileDelete and
setting the ID to the native file ID of the bridge.

When the receiving bridge will get this event it'll look into the
NativeID <> bridge id mapping to find their internal ID and use it to
delete the specific file on their side.

For now this is implemented for slack to discord but this will be add to
other bridges where useful.
@42wim 42wim closed this as completed in 6438a3d Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants