mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 18:59:24 +00:00
Preserve threading between Slack instances (#529)
* Opportunistically preserve Slack threading when parent thread in cache. [#529] * Removed slack-specific processing from gateway. * Added docs. * Add option to enable threading, with default to off. * Did cleanup on @42wim's comments. * Update gateway/gateway.go Co-Authored-By: patcon <patrick.c.connolly@gmail.com> * Suggestion from @42wim :) * Suggestions from @42wim. * More suggestions.
This commit is contained in:
@ -35,6 +35,7 @@ type Message struct {
|
||||
Event string `json:"event"`
|
||||
Protocol string `json:"protocol"`
|
||||
Gateway string `json:"gateway"`
|
||||
ParentID string `json:"parent_id"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
ID string `json:"id"`
|
||||
Extra map[string][]interface{}
|
||||
@ -98,6 +99,7 @@ type Protocol struct {
|
||||
NoTLS bool // mattermost
|
||||
Password string // IRC,mattermost,XMPP,matrix
|
||||
PrefixMessagesWithNick bool // mattemost, slack
|
||||
PreserveThreading bool // slack
|
||||
Protocol string // all protocols
|
||||
QuoteDisable bool // telegram
|
||||
QuoteFormat string // telegram
|
||||
|
@ -171,8 +171,10 @@ func (b *Bslack) handleMessageEvent(ev *slack.MessageEvent) (*config.Message, er
|
||||
Account: b.Account,
|
||||
ID: "slack " + ev.Timestamp,
|
||||
Extra: map[string][]interface{}{},
|
||||
ParentID: ev.ThreadTimestamp,
|
||||
}
|
||||
|
||||
|
||||
if b.useChannelID {
|
||||
rmsg.Channel = "ID:" + channelInfo.ID
|
||||
}
|
||||
|
@ -310,6 +310,10 @@ func (b *Bslack) prepareMessageParameters(msg *config.Message) *slack.PostMessag
|
||||
params.Username = msg.Username
|
||||
params.LinkNames = 1 // replace mentions
|
||||
params.IconURL = config.GetIconURL(msg, b.GetString(iconURLConfig))
|
||||
msgFields := strings.Fields(msg.ParentID)
|
||||
if len(msgFields) >= 2 {
|
||||
params.ThreadTimestamp = msgFields[1]
|
||||
}
|
||||
if msg.Avatar != "" {
|
||||
params.IconURL = msg.Avatar
|
||||
}
|
||||
|
Reference in New Issue
Block a user