Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit b6bffa63f2efc92980f885d9762ef29ea8559748 Author: Wim <wim@42.be> Date: Fri May 06 23:32:25 2022 +0000 Add KeepQuotedReply option for matrix to fix regression (#1823) Matrix quotes replies and as of matterbridge 1.24.0 we strip those as this causes issues with bridges support threading and have PreserveThreading enabled. Introduced via https://github.com/42wim/matterbridge/commit/5bae8f760ba3e9598e10724aba6d099e6ad2e174 But if you for example use mattermost or discord with webhooks you'll need to enable this if you want something that looks like a reply from matrix. See issues: - https://github.com/42wim/matterbridge/issues/1819 - https://github.com/42wim/matterbridge/issues/1780 diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index cd3db76..ad08cd3 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -2728 +2726 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {   // Handle prefix hint for unthreaded messages.   if msg.ParentNotFound() {   msg.ParentID = "" - msg.Text = strings.TrimPrefix(msg.Text, "\n") - msg.Text = fmt.Sprintf("> %s %s", msg.Username, msg.Text)   }     // Use webhook to send the message diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index a252535..702f4c8 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -42812 +42815 @@ func (b *Bmatrix) handleReply(ev *matrix.Event, rmsg config.Message) bool {   }     body := rmsg.Text - for strings.HasPrefix(body, "> ") { - lineIdx := strings.IndexRune(body, '\n') - if lineIdx == -1 { - body = "" - } else { - body = body[(lineIdx + 1):] + + if !b.GetBool("keepquotedreply") { + for strings.HasPrefix(body, "> ") { + lineIdx := strings.IndexRune(body, '\n') + if lineIdx == -1 { + body = "" + } else { + body = body[(lineIdx + 1):] + }   }   }   diff --git a/bridge/mattermost/helpers.go b/bridge/mattermost/helpers.go index 23700a0..c69d94f 100644 --- a/bridge/mattermost/helpers.go +++ b/bridge/mattermost/helpers.go @@ -1836 +1837 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) {   if b.GetBool("PrefixMessagesWithNick") {   msg.Text = msg.Username + msg.Text   } +   if msg.Extra != nil {   // this sends a message only if we received a config.EVENT_FILE_FAILURE_SIZE   for _, rmsg := range helper.HandleExtra(&msg, b.General) { diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index a0fa7c0..f004f4b 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -13286 +132815 @@ HTMLDisable=false  # UseUserName shows the username instead of the server nickname  UseUserName=false   +# Matrix quotes replies and as of matterbridge 1.24.0 we strip those as this causes +# issues with bridges support threading and have PreserveThreading enabled. +# But if you for example use mattermost or discord with webhooks you'll need to enable +# this (and keep PreserveThreading disabled) if you want something that looks like a reply from matrix. +# See issues: +# - https://github.com/42wim/matterbridge/issues/1819 +# - https://github.com/42wim/matterbridge/issues/1780 +KeepQuotedReply=false +  #Nicks you want to ignore.  #Regular expressions supported  #Messages from those users will not be sent to other bridges.