Skip to content

Commit 2177521

Browse files
discord: strip short-lived URL, pass attachment as raw bytes
1 parent 238bae7 commit 2177521

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

bridge/discord/handlers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
211211
go func() {
212212
count := 0
213213
for _, attach := range m.Attachments {
214-
err := b.AddAttachmentFromURL(&rmsg, attach.Filename, attach.ID, "", attach.URL)
214+
// The URL isn't technically private, but it's short-lived so we
215+
// strip it so other networks don't rely on it (attachment passed as bytes).
216+
err := b.AddAttachmentFromProtectedURL(&rmsg, attach.Filename, attach.ID, "", attach.URL)
215217
if err != nil {
216218
b.Log.WithError(err).Warnf("Failed to download attachment %s", attach.Filename)
217219
continue

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
- irc: Leading colon messages are no longer doubled by default as an undocumented hack (eg `:D` -> `::D`); it's now enabled by the `DoubleColonPrefix` setting.
2424
If you are using this setting please help us understand the usecase by commenting
2525
on [issue #122](https://github.com/matterbridge-org/matterbridge/issues/122), otherwise this setting may be deprecated in the near-future.
26+
- discord: Attachments are now passed as raw bytes and reuploaded either to the mediaserver, or to the destination bridges,
27+
as discord CDN URLs are short-lived and people from other bridges would complain about broken URLs
2628

2729
## New Features
2830

0 commit comments

Comments
 (0)