From 767af48cf144ca84eec9edc35b7465350e460903 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Mon, 15 Mar 2021 20:49:58 +1100 Subject: [PATCH 1/2] Allow overriding default channel wide mentions as IRC NOTICEs (#416) --- bridge/mattermost/mattermost.go | 7 ++++++- matterircd.toml.example | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 4836f59e..7a21e505 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -886,13 +886,18 @@ func (m *Mattermost) handleWsActionPost(rmsg *model.WebSocketEvent) { } case strings.Contains(data.Message, "@channel") || strings.Contains(data.Message, "@here") || strings.Contains(data.Message, "@all"): + + messageType := "notice" + if m.v.GetBool("mattermost.disabledefaultmentions") { + messageType = "" + } event := &bridge.Event{ Type: "channel_message", Data: &bridge.ChannelMessageEvent{ Text: msg, ChannelID: data.ChannelId, Sender: ghost, - MessageType: "notice", + MessageType: messageType, ChannelType: channelType, Files: m.getFilesFromData(data), MessageID: data.Id, diff --git a/matterircd.toml.example b/matterircd.toml.example index abdbaec7..c70823e9 100644 --- a/matterircd.toml.example +++ b/matterircd.toml.example @@ -135,6 +135,9 @@ SuffixContext = false #This will show (mention yournick) after a message if it contains one of the words configured #in your mattermost "word that trigger mentions" notifications. ShowMentions = false +# Channel wide default mentions @channel, @all, and @here are shown as IRC NOTICEs. +# This disables that making them appear as normal PRIVMSGs. +#DisableDefaultMentions = true # Path to file to store last viewed information. This is useful for replying only # the messages missed. From 98eab24cf8caeef74ef79cce4a71d952720813f1 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Mon, 15 Mar 2021 21:39:16 +1100 Subject: [PATCH 2/2] Fixed so only original message with channel wide mentions are IRC NOTICEs (#416) --- bridge/mattermost/mattermost.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 7a21e505..68983224 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -735,6 +735,7 @@ func (m *Mattermost) handleWsActionPost(rmsg *model.WebSocketEvent) { return } + replyMessage := "" if data.ParentId != "" { parentPost, resp := m.mc.Client.GetPost(data.ParentId, "") if resp.Error != nil { @@ -744,7 +745,7 @@ func (m *Mattermost) handleWsActionPost(rmsg *model.WebSocketEvent) { if !m.v.GetBool("mattermost.hidereplies") { parentMessage := maybeShorten(parentPost.Message, m.v.GetInt("mattermost.ShortenRepliesTo"), "@", m.v.GetBool("mattermost.unicode")) - data.Message = fmt.Sprintf("%s (re @%s: %s)", data.Message, parentGhost.Nick, parentMessage) + replyMessage = fmt.Sprintf(" (re @%s: %s)", parentGhost.Nick, parentMessage) } } } @@ -809,7 +810,7 @@ func (m *Mattermost) handleWsActionPost(rmsg *model.WebSocketEvent) { return } - msgs := strings.Split(data.Message, "\n") + msgs := strings.Split(data.Message+replyMessage, "\n") channelType := "" if t, ok := props["channel_type"].(string); ok {