From 7c6a162c0f5dd667b4a7cb9a3e031acf12d6ca76 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Mon, 7 Mar 2022 09:42:02 +0100 Subject: [PATCH] Remove MemberShipStateAll --- roomserver/storage/postgres/membership_table.go | 10 ++-------- roomserver/storage/shared/storage.go | 2 -- roomserver/storage/sqlite3/membership_table.go | 9 ++------- roomserver/storage/tables/interface.go | 1 - 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/roomserver/storage/postgres/membership_table.go b/roomserver/storage/postgres/membership_table.go index 33a965457..22d064371 100644 --- a/roomserver/storage/postgres/membership_table.go +++ b/roomserver/storage/postgres/membership_table.go @@ -296,14 +296,8 @@ func (s *membershipStatements) SelectRoomsWithMembership( rows *sql.Rows err error ) - - if membershipState == tables.MemberShipStateAll { - stmt := sqlutil.TxStmt(txn, s.selectRoomsForUserStmt) - rows, err = stmt.QueryContext(ctx, userID) - } else { - stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) - rows, err = stmt.QueryContext(ctx, membershipState, userID) - } + stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) + rows, err = stmt.QueryContext(ctx, membershipState, userID) if err != nil { return nil, err diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index eae8cd2cb..dd49f35ca 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -1046,8 +1046,6 @@ func (d *Database) GetRoomsByMembership(ctx context.Context, userID, membership membershipState = tables.MembershipStateLeaveOrBan case "ban": membershipState = tables.MembershipStateLeaveOrBan - case "all": - membershipState = tables.MemberShipStateAll default: return nil, fmt.Errorf("GetRoomsByMembership: invalid membership %s", membership) } diff --git a/roomserver/storage/sqlite3/membership_table.go b/roomserver/storage/sqlite3/membership_table.go index ff291a3a7..613496882 100644 --- a/roomserver/storage/sqlite3/membership_table.go +++ b/roomserver/storage/sqlite3/membership_table.go @@ -274,13 +274,8 @@ func (s *membershipStatements) SelectRoomsWithMembership( err error ) - if membershipState == tables.MemberShipStateAll { - stmt := sqlutil.TxStmt(txn, s.selectRoomsForUserStmt) - rows, err = stmt.QueryContext(ctx, userID) - } else { - stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) - rows, err = stmt.QueryContext(ctx, membershipState, userID) - } + stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) + rows, err = stmt.QueryContext(ctx, membershipState, userID) if err != nil { return nil, err diff --git a/roomserver/storage/tables/interface.go b/roomserver/storage/tables/interface.go index e814fb0f3..04e3c96cc 100644 --- a/roomserver/storage/tables/interface.go +++ b/roomserver/storage/tables/interface.go @@ -113,7 +113,6 @@ type Invites interface { type MembershipState int64 const ( - MemberShipStateAll MembershipState = 0 MembershipStateLeaveOrBan MembershipState = 1 MembershipStateInvite MembershipState = 2 MembershipStateJoin MembershipState = 3