Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reactions so they're part of threads #530

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type ReactionAddEvent struct {
ChannelType string
ParentUser *UserInfo
Message string
ParentID string
}

type ReactionRemoveEvent ReactionAddEvent
Expand Down
8 changes: 8 additions & 0 deletions bridge/mattermost/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,12 @@ func (m *Mattermost) handleReactionEvent(rmsg *model.WebSocketEvent) {
rMessage = message
}

parentID := reaction.PostId
parentPost, _, err := m.mc.Client.GetPost(reaction.PostId, "")
if err == nil {
parentID = parentPost.RootId
}

switch rmsg.EventType() {
case model.WebsocketEventReactionAdded:
event = &bridge.Event{
Expand All @@ -1335,6 +1341,7 @@ func (m *Mattermost) handleReactionEvent(rmsg *model.WebSocketEvent) {
ChannelType: channelType,
ParentUser: parentUser,
Message: rMessage,
ParentID: parentID,
},
}
case model.WebsocketEventReactionRemoved:
Expand All @@ -1348,6 +1355,7 @@ func (m *Mattermost) handleReactionEvent(rmsg *model.WebSocketEvent) {
ChannelType: channelType,
ParentUser: parentUser,
Message: rMessage,
ParentID: parentID,
},
}
}
Expand Down
10 changes: 6 additions & 4 deletions mm-go-irckit/userbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ func (u *User) handleStatusChangeEvent(event *bridge.StatusChangeEvent) {

func (u *User) handleReactionEvent(event interface{}) {
var (
text, channelID, messageID, channelType, reaction string
sender *bridge.UserInfo
text, channelID, messageID, parentID, channelType, reaction string
sender *bridge.UserInfo
)

message := ""
Expand All @@ -415,6 +415,7 @@ func (u *User) handleReactionEvent(event interface{}) {
sender = e.Sender
channelType = e.ChannelType
reaction = e.Reaction
parentID = e.ParentID
case *bridge.ReactionRemoveEvent:
message = e.Message
text = "removed reaction: "
Expand All @@ -423,6 +424,7 @@ func (u *User) handleReactionEvent(event interface{}) {
sender = e.Sender
channelType = e.ChannelType
reaction = e.Reaction
parentID = e.ParentID
}

defer u.saveLastViewedAt(channelID)
Expand All @@ -440,7 +442,7 @@ func (u *User) handleReactionEvent(event interface{}) {
Sender: sender,
MessageID: messageID,
Event: "reaction",
ParentID: messageID,
ParentID: parentID,
}

u.handleDirectMessageEvent(e)
Expand All @@ -454,7 +456,7 @@ func (u *User) handleReactionEvent(event interface{}) {
Sender: sender,
MessageID: messageID,
Event: "reaction",
ParentID: messageID,
ParentID: parentID,
}

u.handleChannelMessageEvent(e)
Expand Down