diff options
author | Kegsay <kegan@matrix.org> | 2020-09-04 14:25:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 14:25:01 +0100 |
commit | ca8dcf46b746686e213b184c3ae42ba0be17b46b (patch) | |
tree | 25a1708a15e8ec0cf2ab6d0a574411ce8e31cc87 /roomserver | |
parent | 81688d6bde5e544d11691e5b137eb444a35c9d32 (diff) |
Remove QuerySharedUsers from current state server (#1396)
* Remove QuerySharedUsers from current state server
* Bugfixes
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/storage/postgres/rooms_table.go | 4 | ||||
-rw-r--r-- | roomserver/storage/shared/storage.go | 7 | ||||
-rw-r--r-- | roomserver/storage/sqlite3/membership_table.go | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/roomserver/storage/postgres/rooms_table.go b/roomserver/storage/postgres/rooms_table.go index ef1b7891..ce635210 100644 --- a/roomserver/storage/postgres/rooms_table.go +++ b/roomserver/storage/postgres/rooms_table.go @@ -79,10 +79,10 @@ const selectRoomIDsSQL = "" + "SELECT room_id FROM roomserver_rooms" const bulkSelectRoomIDsSQL = "" + - "SELECT room_id FROM roomserver_rooms WHERE room_nid IN ($1)" + "SELECT room_id FROM roomserver_rooms WHERE room_nid = ANY($1)" const bulkSelectRoomNIDsSQL = "" + - "SELECT room_nid FROM roomserver_rooms WHERE room_id IN ($1)" + "SELECT room_nid FROM roomserver_rooms WHERE room_id = ANY($1)" type roomStatements struct { insertRoomNIDStmt *sql.Stmt diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index a3b33a4f..7e1ccd16 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -774,15 +774,18 @@ func (d *Database) GetRoomsByMembership(ctx context.Context, userID, membership } stateKeyNID, err := d.EventStateKeysTable.SelectEventStateKeyNID(ctx, nil, userID) if err != nil { + if err == sql.ErrNoRows { + return nil, nil + } return nil, fmt.Errorf("GetRoomsByMembership: cannot map user ID to state key NID: %w", err) } roomNIDs, err := d.MembershipTable.SelectRoomsWithMembership(ctx, stateKeyNID, membershipState) if err != nil { - return nil, err + return nil, fmt.Errorf("GetRoomsByMembership: failed to SelectRoomsWithMembership: %w", err) } roomIDs, err := d.RoomsTable.BulkSelectRoomIDs(ctx, roomNIDs) if err != nil { - return nil, err + return nil, fmt.Errorf("GetRoomsByMembership: failed to lookup room nids: %w", err) } if len(roomIDs) != len(roomNIDs) { return nil, fmt.Errorf("GetRoomsByMembership: missing room IDs, got %d want %d", len(roomIDs), len(roomNIDs)) diff --git a/roomserver/storage/sqlite3/membership_table.go b/roomserver/storage/sqlite3/membership_table.go index 0d5ce516..bb1ab39a 100644 --- a/roomserver/storage/sqlite3/membership_table.go +++ b/roomserver/storage/sqlite3/membership_table.go @@ -41,7 +41,7 @@ const membershipSchema = ` ` var selectJoinedUsersSetForRoomsSQL = "" + - "SELECT target_nid, COUNT(room_nid) FROM roomserver_membership WHERE room_nid = ANY($1) AND" + + "SELECT target_nid, COUNT(room_nid) FROM roomserver_membership WHERE room_nid IN ($1) AND" + " membership_nid = " + fmt.Sprintf("%d", tables.MembershipStateJoin) + " GROUP BY target_nid" // Insert a row in to membership table so that it can be locked by the |