mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-25 21:21:35 +00:00
Fix invite -> leave -> join
dance when accepting invites (#2817)
As mentioned in https://github.com/matrix-org/dendrite/issues/2361#issuecomment-1139394565 and observed by ourselves, this should fix the odd `invite -> leave -> join` dance when accepting invites.
This commit is contained in:
parent
73e02463cf
commit
40cfb9a4ea
@ -428,6 +428,13 @@ func (s *OutputRoomEventConsumer) onRetireInviteEvent(
|
||||
return
|
||||
}
|
||||
|
||||
// Only notify clients about retired invite events, if the user didn't accept the invite.
|
||||
// The PDU stream will also receive an event about accepting the invitation, so there should
|
||||
// be a "smooth" transition from invite -> join, and not invite -> leave -> join
|
||||
if msg.Membership == gomatrixserverlib.Join {
|
||||
return
|
||||
}
|
||||
|
||||
// Notify any active sync requests that the invite has been retired.
|
||||
s.inviteStream.Advance(pduPos)
|
||||
s.notifier.OnNewInvite(types.StreamingToken{InvitePosition: pduPos}, msg.TargetUserID)
|
||||
|
@ -74,7 +74,12 @@ func (p *InviteStreamProvider) IncrementalSync(
|
||||
return to
|
||||
}
|
||||
for roomID := range retiredInvites {
|
||||
if _, ok := req.Response.Rooms.Join[roomID]; !ok {
|
||||
if _, ok := req.Response.Rooms.Invite[roomID]; ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := req.Response.Rooms.Join[roomID]; ok {
|
||||
continue
|
||||
}
|
||||
lr := types.NewLeaveResponse()
|
||||
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
|
||||
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
|
||||
@ -88,7 +93,7 @@ func (p *InviteStreamProvider) IncrementalSync(
|
||||
Content: gomatrixserverlib.RawJSON(`{"membership":"leave"}`),
|
||||
})
|
||||
req.Response.Rooms.Leave[roomID] = lr
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return maxID
|
||||
|
Loading…
Reference in New Issue
Block a user