commit 90cf9e1589b192358fc410829d007899fd282ca0
Author: Qais Patankar <qaisjp@gmail.com>
Date: Thu Dec 31 18:01:57 2020 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 7dbbc80..9893520 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -296 +298 @@ const (
EventNoticeIRC = "notice_irc"
)
+const ParentIDNotFound = "msg-parent-not-found"
+
type Message struct {
Text string `json:"text"`
Channel string `json:"channel"`
@@ -456 +4714 @@ type Message struct {
Extra map[string][]interface{}
}
+func (m Message) ParentNotFound() bool {
+ return m.ParentID == ParentIDNotFound
+}
+
+func (m Message) ParentValid() bool {
+ return m.ParentID != "" && !m.ParentNotFound()
+}
+
type FileInfo struct {
Name string
Data *[]byte
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index daeaa40..184dde8 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -2437 +2437 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
}
// Handle prefix hint for unthreaded messages.
- if msg.ParentID == "msg-parent-not-found" {
+ if msg.ParentNotFound() {
msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
}
@@ -2977 +2977 @@ func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (st
Content: msg.Username + msg.Text,
}
- if msg.ParentID != "" && msg.ParentID != "msg-parent-not-found" {
+ if msg.ParentValid() {
m.Reference = &discordgo.MessageReference{
MessageID: msg.ParentID,
ChannelID: channelID,
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 2c11b79..bb44c48 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -1227 +1227 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
}
// Handle prefix hint for unthreaded messages.
- if msg.ParentID == "msg-parent-not-found" {
+ if msg.ParentNotFound() {
msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
}
diff --git a/bridge/msteams/msteams.go b/bridge/msteams/msteams.go
index 4d4acc2..87a15a7 100644
--- a/bridge/msteams/msteams.go
+++ b/bridge/msteams/msteams.go
@@ -8613 +8616 @@ func (b *Bmsteams) JoinChannel(channel config.ChannelInfo) error {
func (b *Bmsteams) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
- if msg.ParentID != "" && msg.ParentID != "msg-parent-not-found" {
+ if msg.ParentValid() {
return b.sendReply(msg)
}
- if msg.ParentID == "msg-parent-not-found" {
+
+ // Handle prefix hint for unthreaded messages.
+ if msg.ParentNotFound() {
msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
}
+
ct := b.gc.Teams().ID(b.GetString("TeamID")).Channels().ID(msg.Channel).Messages().Request()
text := msg.Username + msg.Text
content := &msgraph.ItemBody{Content: &text}
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 384581e..e016a64 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -2997 +2997 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
}
// Handle prefix hint for unthreaded messages.
- if msg.ParentID == "msg-parent-not-found" {
+ if msg.ParentNotFound() {
msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
}
diff --git a/gateway/gateway.go b/gateway/gateway.go
index eb530af..aa7144f 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -4599 +4599 @@ func (gw *Gateway) SendMessage(
}
// if the parentID is still empty and we have a parentID set in the original message
- // this means that we didn't find it in the cache so set it "msg-parent-not-found"
+ // this means that we didn't find it in the cache so set it to a "msg-parent-not-found" constant
if msg.ParentID == "" && rmsg.ParentID != "" {
- msg.ParentID = "msg-parent-not-found"
+ msg.ParentID = config.ParentIDNotFound
}
drop, err := gw.modifyOutMessageTengo(rmsg, &msg, dest)