Skip to content

Commit

Permalink
handlegmessages: never double puppet incoming messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 2, 2024
1 parent 4e35033 commit 46cbfda
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/connector/handlegmessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (r *ReactionSyncEvent) GetReactions() *bridgev2.ReactionSyncData {
data.Users[userID] = reacts
}
reacts.Reactions = append(reacts.Reactions, &bridgev2.BackfillReaction{
Sender: r.g.makeEventSender(participantID, false),
Sender: r.g.makeEventSender(participantID, false, false),
Emoji: emoji,
ExtraContent: extraData,
})
Expand Down Expand Up @@ -594,13 +594,14 @@ func (gc *GMClient) getEventSenderFromMessage(m *gmproto.Message) bridgev2.Event
if status >= 200 && status < 300 {
return bridgev2.EventSender{}
}
// Statuses between 1 and 100 are outgoing types
// Statuses between 1 and 100 are outgoing types, 100-200 are incoming
forceOutgoing := status >= 1 && status < 100
return gc.makeEventSender(m.ParticipantID, forceOutgoing)
forceIncoming := status >= 100 && status < 200
return gc.makeEventSender(m.ParticipantID, forceOutgoing, forceIncoming)
}

func (gc *GMClient) makeEventSender(participantID string, forceOutgoing bool) bridgev2.EventSender {
isFromMe := forceOutgoing || participantID == "1" || gc.Meta.IsSelfParticipantID(participantID)
func (gc *GMClient) makeEventSender(participantID string, forceOutgoing, forceIncoming bool) bridgev2.EventSender {
isFromMe := !forceIncoming && (forceOutgoing || participantID == "1" || gc.Meta.IsSelfParticipantID(participantID))
return bridgev2.EventSender{
IsFromMe: isFromMe,
Sender: gc.MakeUserID(participantID),
Expand Down

0 comments on commit 46cbfda

Please sign in to comment.