Skip to content

Commit

Permalink
handlegmessages: add hack to prevent notifying about old reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 29, 2024
1 parent 67c3982 commit 1b862e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/connector/handlegmessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ func (r *ReactionSyncEvent) GetReactions() *bridgev2.ReactionSyncData {
Users: make(map[networkid.UserID]*bridgev2.ReactionSyncUser),
HasAllUsers: true,
}
var extraData map[string]any
if time.Since(time.UnixMicro(r.Timestamp)) > 1*24*time.Hour {
// Extremely hacky hack to prevent notifications for reactions to old messages
extraData = map[string]any{
"org.matrix.msc2716.historical": true,
}
}
addReaction := func(participantID, emoji string) {
userID := r.g.MakeUserID(participantID)
reacts, ok := data.Users[userID]
Expand All @@ -404,8 +411,9 @@ func (r *ReactionSyncEvent) GetReactions() *bridgev2.ReactionSyncData {
data.Users[userID] = reacts
}
reacts.Reactions = append(reacts.Reactions, &bridgev2.BackfillReaction{
Sender: r.g.makeEventSender(participantID, false),
Emoji: emoji,
Sender: r.g.makeEventSender(participantID, false),
Emoji: emoji,
ExtraContent: extraData,
})
}
for _, reaction := range r.Reactions {
Expand Down

0 comments on commit 1b862e8

Please sign in to comment.