From eb9a91631f72f2d3ad48feba4423265bc8ef4df2 Mon Sep 17 00:00:00 2001 From: selfhoster1312 Date: Mon, 2 Mar 2026 10:40:09 +0100 Subject: [PATCH] discord: strip short-lived URL, pass attachment as raw bytes --- bridge/discord/handlers.go | 4 +++- changelog.md | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go index 16bb9977f..e2c4683eb 100644 --- a/bridge/discord/handlers.go +++ b/bridge/discord/handlers.go @@ -211,7 +211,9 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat go func() { count := 0 for _, attach := range m.Attachments { - err := b.AddAttachmentFromURL(&rmsg, attach.Filename, attach.ID, "", attach.URL) + // The URL isn't technically private, but it's short-lived so we + // strip it so other networks don't rely on it (attachment passed as bytes). + err := b.AddAttachmentFromProtectedURL(&rmsg, attach.Filename, attach.ID, "", attach.URL) if err != nil { b.Log.WithError(err).Warnf("Failed to download attachment %s", attach.Filename) continue diff --git a/changelog.md b/changelog.md index 719d5e449..1633e2364 100644 --- a/changelog.md +++ b/changelog.md @@ -23,6 +23,9 @@ - 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. If you are using this setting please help us understand the usecase by commenting on [issue #122](https://github.com/matterbridge-org/matterbridge/issues/122), otherwise this setting may be deprecated in the near-future. +- discord: Attachments are now passed as raw bytes and reuploaded either to the mediaserver, or to the destination bridges, + as discord CDN URLs are short-lived and people from other bridges would complain about broken URLs; this means IRC users will + no longer receive discord attachments as URLs unless a mediaserver is configured ([#170](https://github.com/matterbridge-org/matterbridge/pull/170)) ## New Features