Skip to content

Commit

Permalink
only ensureJoined if not already joined
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 committed Feb 15, 2024
1 parent 668134d commit f7c9ccd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2131,21 +2131,27 @@ func (portal *Portal) SyncParticipants(ctx context.Context, source *User, info *
if member.UserID != source.SignalID && portal.MXID != "" {
userIDs[intent.UserID] = ((int)(member.Role) >> 1) * 50
}
delete(currentMembers, intent.UserID)
if portal.MXID != "" {
err := intent.EnsureJoined(ctx, portal.MXID)
if err != nil {
log.Err(err).Stringer("signal_user_id", member.UserID).Msg("Failed to ensure user is joined to portal")
if currentMembers[intent.UserID] != event.MembershipJoin {
err := intent.EnsureJoined(ctx, portal.MXID)
if err != nil {
log.Err(err).Stringer("signal_user_id", member.UserID).Msg("Failed to ensure user is joined to portal")
}
}
if puppet.customIntent == nil {
user := portal.bridge.GetUserBySignalID(member.UserID)
if user != nil {
delete(currentMembers, user.MXID)
currentMembership := currentMembers[user.MXID]
if currentMembership == event.MembershipJoin || currentMembership == event.MembershipInvite {
continue
}
user.ensureInvited(ctx, intent, portal.MXID, false)
userIDs[user.MXID] = ((int)(member.Role) >> 1) * 50
delete(currentMembers, user.MXID)
}
}
}
delete(currentMembers, intent.UserID)
}
if portal.MXID == "" {
return userIDs
Expand Down

0 comments on commit f7c9ccd

Please sign in to comment.