Skip to content

Support Discord Reply (fix #43)#124

Merged
poVoq merged 1 commit intomatterbridge-org:masterfrom
lekoOwO:mattermost-org/feature/discord-reply
Feb 21, 2026
Merged

Support Discord Reply (fix #43)#124
poVoq merged 1 commit intomatterbridge-org:masterfrom
lekoOwO:mattermost-org/feature/discord-reply

Conversation

@lekoOwO
Copy link

@lekoOwO lekoOwO commented Jan 10, 2026

Fixes #43

@lekoOwO lekoOwO force-pushed the mattermost-org/feature/discord-reply branch from 2b48f34 to 52bf0ee Compare January 10, 2026 23:10
@selfhoster1312
Copy link
Collaborator

Hello, thanks for submitting this PR here.

I'm not yet very familiar how the reply system works, but i know it uses properties and methods on config.Message: Message.Parent and Message.ParentValid() notably. If you have time to dig around and experiment, that's great!

Editing rmsg.Text is definitely a hacky solution that will prevent interoperability with other protocols, because the other protocol won't know it's a reply and format it properly. I mean i say another protocol, but you could observe it between two discord channels for examples.

I'm sorry it's not well documented yet. This is an area we haven't touched since forking, we've been more focused on file attachments for the moment.

return msg
}
refMsgRef := m.MessageReference
refMsg, err := s.ChannelMessage(refMsgRef.ChannelID, refMsgRef.MessageID)
Copy link
Collaborator

@selfhoster1312 selfhoster1312 Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a blocking network request, and should not be performed on the main thread (because it will block processing other events if the discord API takes some time). There's many ways to work around that. One would be instead of returning string from the method, you could return a boolean indicating whether the method is in fact handling a reply:

  • if it is, just ignore it in the createMessage method, and start a new goroutine in handleQuote
  • if it's not, keep going with the original msg

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative could be to store the last ~100 messages or so per channel, so we don't have to do a network query at all.

@kousu
Copy link

kousu commented Feb 19, 2026

Oh I just noticed this! This contrasts with #135 and #134. I assume you run a bridge that doesn't support reply tags, like IRC or Mumble. I mostly use XMPP though so I want the direct opposite approach.

  • Discord -> IRC bridging: add a quote in msg.Text
  • XMPP -> Discord: strip quotes from msg.Text

I don't want Discord -> XMPP to add quotes, they'll be messy and redundant for my case.

I wonder if the reply system needs to reworked at gateway/gateway.go level. It would be cleaner if the incoming bridge handled parsing the reply tag into Message.ParentID and separating message (message.Text) from quote (currently not stored), while the outgoing bridge could decide whether to translate Message.ParentID into its native reply tag format and whether to glue Message.Text back together with the quote. There's nowhere to separate quote text at the moment, so that would have to be added.

@poVoq
Copy link
Collaborator

poVoq commented Feb 20, 2026

I wonder if the reply system needs to reworked at gateway/gateway.go level. It would be cleaner if the incoming bridge handled parsing the reply tag into Message.ParentID and separating message (message.Text) from quote (currently not stored), while the outgoing bridge could decide whether to translate Message.ParentID into its native reply tag format and whether to glue Message.Text back together with the quote. There's nowhere to separate quote text at the moment, so that would have to be added.

If you want to give it a shot, that would certainly be appreciated. I guess in the mean-time we could merge this as a temporary solution?

@kousu
Copy link

kousu commented Feb 20, 2026

If you want to give it a shot, that would certainly be appreciated

Okay thanks for the vote of confidence in that direction :)

I guess in the mean-time we could merge this as a temporary solution?

For what it's worth, I vote yes, keep the improvements coming ! It's crazy that the fix stalled out for 4 years.

@poVoq poVoq merged commit 47b80d7 into matterbridge-org:master Feb 21, 2026
7 checks passed
@poVoq
Copy link
Collaborator

poVoq commented Feb 21, 2026

Thanks!

@selfhoster1312
Copy link
Collaborator

selfhoster1312 commented Feb 21, 2026

I guess in the mean-time we could merge this as a temporary solution?

That's reasonable. I opened #142 to track implementation of a new replies system.

In the meantime, if there are any breaking changes in this PR, can someone who understands them (i.e. someone who uses Discord) open a new PR to update the changelog?

EDIT: of course if there are no breaking changes, a changelog entry is more than welcome anyway, just not in the "breaking changes" section

@kousu
Copy link

kousu commented Feb 21, 2026

In the meantime, if there are any breaking changes in this PR, can someone who understands them (i.e. someone who uses Discord) open a new PR to update the changelog?

I built and deployed (for ref: from) with this patch in. Just rebooting led to this duplication, which I expected:

image

The quote box is the <reply> from #134, and the "@kousu: XMPP" is from this PR, redundantly. Any bridge that understands replies natively is going to do the same thing unless someone sets QuoteDisable=true, so that's probably worth a note in the changelog: #144

kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
@kousu kousu mentioned this pull request Feb 21, 2026
@selfhoster1312
Copy link
Collaborator

I'll trust your judgement on whether this should be the default behavior or not (it's not too late to make a new PR to disable it by default) :)

kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
kousu added a commit to kousu/matterbridge that referenced this pull request Feb 21, 2026
poVoq pushed a commit that referenced this pull request Feb 21, 2026
poVoq pushed a commit that referenced this pull request Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Discord replies not being relayed properly

4 participants