diff --git a/pkg/connector/groupinfo.go b/pkg/connector/groupinfo.go index d0ecdd49..156e34a5 100644 --- a/pkg/connector/groupinfo.go +++ b/pkg/connector/groupinfo.go @@ -238,10 +238,27 @@ func (s *SignalClient) groupChangeToChatInfoChange(ctx context.Context, rev uint Membership: event.MembershipJoin, }) } + bannedMembers := make(map[libsignalgo.ServiceID]bridgev2.ChatMember) + for _, member := range groupChange.AddBannedMembers { + aci := s.maybeResolvePNItoACI(ctx, &member.ServiceID) + if aci == nil { + continue + } + bannedMembers[member.ServiceID] = bridgev2.ChatMember{ + EventSender: s.makeEventSender(*aci), + Membership: event.MembershipBan, + } + } for _, memberACI := range groupChange.DeleteMembers { + membership := event.MembershipLeave + serviceID := libsignalgo.NewACIServiceID(*memberACI) + if _, ok := bannedMembers[serviceID]; ok { + membership = event.MembershipBan + delete(bannedMembers, serviceID) + } mc = append(mc, bridgev2.ChatMember{ EventSender: s.makeEventSender(*memberACI), - Membership: event.MembershipLeave, + Membership: membership, PrevMembership: event.MembershipJoin, }) } @@ -261,9 +278,14 @@ func (s *SignalClient) groupChangeToChatInfoChange(ctx context.Context, rev uint if aci == nil { continue } + membership := event.MembershipLeave + if _, ok := bannedMembers[*memberServiceID]; ok { + membership = event.MembershipBan + delete(bannedMembers, *memberServiceID) + } mc = append(mc, bridgev2.ChatMember{ EventSender: s.makeEventSender(*aci), - Membership: event.MembershipLeave, + Membership: membership, PrevMembership: event.MembershipInvite, }) } @@ -274,21 +296,20 @@ func (s *SignalClient) groupChangeToChatInfoChange(ctx context.Context, rev uint }) } for _, memberACI := range groupChange.DeleteRequestingMembers { + membership := event.MembershipLeave + serviceID := libsignalgo.NewACIServiceID(*memberACI) + if _, ok := bannedMembers[serviceID]; ok { + membership = event.MembershipBan + delete(bannedMembers, serviceID) + } mc = append(mc, bridgev2.ChatMember{ EventSender: s.makeEventSender(*memberACI), - Membership: event.MembershipLeave, + Membership: membership, PrevMembership: event.MembershipKnock, }) } - for _, member := range groupChange.AddBannedMembers { - aci := s.maybeResolvePNItoACI(ctx, &member.ServiceID) - if aci == nil { - continue - } - mc = append(mc, bridgev2.ChatMember{ - EventSender: s.makeEventSender(*aci), - Membership: event.MembershipBan, - }) + for _, chatMember := range bannedMembers { + mc = append(mc, chatMember) } for _, memberServiceID := range groupChange.DeleteBannedMembers { aci := s.maybeResolvePNItoACI(ctx, memberServiceID)