mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 17:23:09 -06:00
Fix Forget Room bug that prevented Room Deletion (#16)
- Fix membership Insert to ensure the OnConflict performs an Update if exists - Fix type in the rooms bulkSelectRoomNIDsSQL Co-authored-by: alexf@example.com <alexf@example.com>
This commit is contained in:
parent
fd7f25479b
commit
032ad5b052
|
|
@ -297,13 +297,23 @@ func (s *membershipStatements) InsertMembership(
|
|||
cosmosDocId := cosmosdbapi.GetDocumentId(s.db.cosmosConfig.TenantName, dbCollectionName, docId)
|
||||
pk := cosmosdbapi.GetPartitionKey(s.db.cosmosConfig.TenantName, dbCollectionName)
|
||||
|
||||
// " ON CONFLICT DO NOTHING"
|
||||
exists, _ := getMembership(s, ctx, pk, cosmosDocId)
|
||||
if exists != nil {
|
||||
exists.Membership.RoomNID = int64(roomNID)
|
||||
exists.Membership.TargetNID = int64(targetUserNID)
|
||||
exists.Membership.TargetLocal = localTarget
|
||||
_, errSet := setMembership(s, ctx, *exists)
|
||||
return errSet
|
||||
}
|
||||
|
||||
data := MembershipCosmos{
|
||||
EventNID: 0,
|
||||
Forgotten: false,
|
||||
MembershipNID: 1,
|
||||
RoomNID: int64(roomNID),
|
||||
SenderNID: 0,
|
||||
TargetLocal: false,
|
||||
TargetLocal: localTarget,
|
||||
TargetNID: int64(targetUserNID),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ const bulkSelectRoomIDsSQL = "" +
|
|||
// "SELECT room_nid FROM roomserver_rooms WHERE room_id IN ($1)"
|
||||
const bulkSelectRoomNIDsSQL = "" +
|
||||
"select * from c where c._cn = @x1 " +
|
||||
"and ARRAY_CONTAINS(@x2, c.mx_roomserver_room.room_nid)"
|
||||
"and ARRAY_CONTAINS(@x2, c.mx_roomserver_room.room_id)"
|
||||
|
||||
type roomStatements struct {
|
||||
db *Database
|
||||
|
|
|
|||
Loading…
Reference in a new issue