mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -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)
|
cosmosDocId := cosmosdbapi.GetDocumentId(s.db.cosmosConfig.TenantName, dbCollectionName, docId)
|
||||||
pk := cosmosdbapi.GetPartitionKey(s.db.cosmosConfig.TenantName, dbCollectionName)
|
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{
|
data := MembershipCosmos{
|
||||||
EventNID: 0,
|
EventNID: 0,
|
||||||
Forgotten: false,
|
Forgotten: false,
|
||||||
MembershipNID: 1,
|
MembershipNID: 1,
|
||||||
RoomNID: int64(roomNID),
|
RoomNID: int64(roomNID),
|
||||||
SenderNID: 0,
|
SenderNID: 0,
|
||||||
TargetLocal: false,
|
TargetLocal: localTarget,
|
||||||
TargetNID: int64(targetUserNID),
|
TargetNID: int64(targetUserNID),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ const bulkSelectRoomIDsSQL = "" +
|
||||||
// "SELECT room_nid FROM roomserver_rooms WHERE room_id IN ($1)"
|
// "SELECT room_nid FROM roomserver_rooms WHERE room_id IN ($1)"
|
||||||
const bulkSelectRoomNIDsSQL = "" +
|
const bulkSelectRoomNIDsSQL = "" +
|
||||||
"select * from c where c._cn = @x1 " +
|
"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 {
|
type roomStatements struct {
|
||||||
db *Database
|
db *Database
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue