From 6438a3dba3c4cb241f1e2633ae6b23efd113d684 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 5 Feb 2022 14:45:54 +0100 Subject: Add support for deleting files from slack to discord. Fixes #1705 (#1709) 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. --- bridge/config/config.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'bridge/config') diff --git a/bridge/config/config.go b/bridge/config/config.go index 7b7c2f2e..16b397f3 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -23,6 +23,7 @@ const ( EventRejoinChannels = "rejoin_channels" EventUserAction = "user_action" EventMsgDelete = "msg_delete" + EventFileDelete = "file_delete" EventAPIConnected = "api_connected" EventUserTyping = "user_typing" EventGetChannelMembers = "get_channel_members" @@ -56,13 +57,14 @@ func (m Message) ParentValid() bool { } type FileInfo struct { - Name string - Data *[]byte - Comment string - URL string - Size int64 - Avatar bool - SHA string + Name string + Data *[]byte + Comment string + URL string + Size int64 + Avatar bool + SHA string + NativeID string } type ChannelInfo struct { -- cgit v1.2.3