From 3e736b3628b640106238f743fe81aba7c45875f8 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 15 Mar 2022 09:28:05 +0100 Subject: [PATCH] Get rooms where user is either a member or send an event --- syncapi/storage/postgres/current_room_state_table.go | 2 +- syncapi/storage/sqlite3/current_room_state_table.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/syncapi/storage/postgres/current_room_state_table.go b/syncapi/storage/postgres/current_room_state_table.go index d646a0e41..d202183a9 100644 --- a/syncapi/storage/postgres/current_room_state_table.go +++ b/syncapi/storage/postgres/current_room_state_table.go @@ -75,7 +75,7 @@ const DeleteRoomStateForRoomSQL = "" + "DELETE FROM syncapi_current_room_state WHERE event_id = $1" const selectRoomIDsWithMembershipSQL = "" + - "SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2" + "SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE (type = 'm.room.member' AND state_key = $1 AND membership = $2) OR sender = $1" const selectRoomIDsWithAnyMembershipSQL = "" + "SELECT DISTINCT room_id, membership FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1" diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go index 587f9d240..81c0d694e 100644 --- a/syncapi/storage/sqlite3/current_room_state_table.go +++ b/syncapi/storage/sqlite3/current_room_state_table.go @@ -64,7 +64,7 @@ const DeleteRoomStateForRoomSQL = "" + "DELETE FROM syncapi_current_room_state WHERE event_id = $1" const selectRoomIDsWithMembershipSQL = "" + - "SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2" + "SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE (type = 'm.room.member' AND state_key = $1 AND membership = $2) OR sender = $3" const selectRoomIDsWithAnyMembershipSQL = "" + "SELECT DISTINCT room_id, membership FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1" @@ -165,7 +165,7 @@ func (s *currentRoomStateStatements) SelectRoomIDsWithMembership( membership string, // nolint: unparam ) ([]string, error) { stmt := sqlutil.TxStmt(txn, s.selectRoomIDsWithMembershipStmt) - rows, err := stmt.QueryContext(ctx, userID, membership) + rows, err := stmt.QueryContext(ctx, userID, membership, userID) if err != nil { return nil, err }