summaryrefslogtreecommitdiffstats
path: root/bridge/helper/helper.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-02-05 14:45:54 +0100
committerGitHub <noreply@github.com>2022-02-05 14:45:54 +0100
commit6438a3dba3c4cb241f1e2633ae6b23efd113d684 (patch)
treed13fe894fc1a20b19c2fe3fdb16b6b24e74bc721 /bridge/helper/helper.go
parent4b226a6a638b7572c0fcbf8964bfb02e675b2e6b (diff)
downloadmatterbridge-msglm-6438a3dba3c4cb241f1e2633ae6b23efd113d684.tar.gz
matterbridge-msglm-6438a3dba3c4cb241f1e2633ae6b23efd113d684.tar.bz2
matterbridge-msglm-6438a3dba3c4cb241f1e2633ae6b23efd113d684.zip
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.
Diffstat (limited to 'bridge/helper/helper.go')
-rw-r--r--bridge/helper/helper.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go
index 581a2c43..fb65d8d9 100644
--- a/bridge/helper/helper.go
+++ b/bridge/helper/helper.go
@@ -168,17 +168,23 @@ func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string,
// HandleDownloadData adds the data for a remote file into a Matterbridge gateway message.
func HandleDownloadData(logger *logrus.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol) {
+ HandleDownloadData2(logger, msg, name, "", comment, url, data, general)
+}
+
+// HandleDownloadData adds the data for a remote file into a Matterbridge gateway message.
+func HandleDownloadData2(logger *logrus.Entry, msg *config.Message, name, id, comment, url string, data *[]byte, general *config.Protocol) {
var avatar bool
logger.Debugf("Download OK %#v %#v", name, len(*data))
if msg.Event == config.EventAvatarDownload {
avatar = true
}
msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{
- Name: name,
- Data: data,
- URL: url,
- Comment: comment,
- Avatar: avatar,
+ Name: name,
+ Data: data,
+ URL: url,
+ Comment: comment,
+ Avatar: avatar,
+ NativeID: id,
})
}