mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Fix issue where a member is forced to leave a room when the invite is marked deleted
This commit is contained in:
parent
a2706e6498
commit
04f268e6d7
|
|
@ -74,12 +74,19 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
return to
|
||||
}
|
||||
for roomID := range retiredInvites {
|
||||
if _, ok := req.Response.Rooms.Invite[roomID]; ok {
|
||||
if req.Response.Rooms.Invite[roomID] != nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := req.Response.Rooms.Join[roomID]; ok {
|
||||
if req.Response.Rooms.Join[roomID] != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
joinedUsers, err := snapshot.AllJoinedUsersInRoom(ctx, []string{roomID})
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !contains(joinedUsers[roomID], req.Device.UserID) {
|
||||
lr := types.NewLeaveResponse()
|
||||
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
|
||||
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
|
||||
|
|
@ -93,8 +100,17 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
Content: gomatrixserverlib.RawJSON(`{"membership":"leave"}`),
|
||||
})
|
||||
req.Response.Rooms.Leave[roomID] = lr
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return maxID
|
||||
}
|
||||
|
||||
func contains(values []string, findVal string) bool {
|
||||
for _, v := range values {
|
||||
if v == findVal {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue