From 2521d9ccb7055de762588ed40e2876b81effab9a Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:27:34 +0200 Subject: [PATCH] Partly revert changes of #264 --- sync3/dispatcher.go | 4 ---- sync3/handler/connstate.go | 4 ++-- sync3/handler/connstate_test.go | 4 ---- sync3/tracker.go | 12 ------------ sync3/tracker_test.go | 5 ----- 5 files changed, 2 insertions(+), 27 deletions(-) diff --git a/sync3/dispatcher.go b/sync3/dispatcher.go index 949e25ab..12ddfeb9 100644 --- a/sync3/dispatcher.go +++ b/sync3/dispatcher.go @@ -47,10 +47,6 @@ func (d *Dispatcher) IsUserJoined(userID, roomID string) bool { return d.jrt.IsUserJoined(userID, roomID) } -func (d *Dispatcher) IsUserInvited(userID, roomID string) bool { - return d.jrt.IsUserInvited(userID, roomID) -} - // Load joined members into the dispatcher. // MUST BE CALLED BEFORE V2 POLL LOOPS START. func (d *Dispatcher) Startup(roomToJoinedUsers map[string][]string) error { diff --git a/sync3/handler/connstate.go b/sync3/handler/connstate.go index 671ee9e4..eba0ca43 100644 --- a/sync3/handler/connstate.go +++ b/sync3/handler/connstate.go @@ -15,7 +15,6 @@ import ( type JoinChecker interface { IsUserJoined(userID, roomID string) bool - IsUserInvited(userID, roomID string) bool } // ConnState tracks all high-level connection state for this connection, like the combined request @@ -596,7 +595,8 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu // since we'll be using the invite_state only. loadRoomIDs := make([]string, 0, len(roomIDs)) for _, roomID := range roomIDs { - if !s.joinChecker.IsUserInvited(s.userID, roomID) { + userRoomData, ok := roomIDToUserRoomData[roomID] + if !ok || !userRoomData.IsInvite { loadRoomIDs = append(loadRoomIDs, roomID) } } diff --git a/sync3/handler/connstate_test.go b/sync3/handler/connstate_test.go index e7c97b96..46c00d6c 100644 --- a/sync3/handler/connstate_test.go +++ b/sync3/handler/connstate_test.go @@ -31,10 +31,6 @@ func (t *NopJoinTracker) IsUserJoined(userID, roomID string) bool { return true } -func (t *NopJoinTracker) IsUserInvited(userID, roomID string) bool { - return true -} - type NopTransactionFetcher struct{} func (t *NopTransactionFetcher) TransactionIDForEvents(userID, deviceID string, eventIDs []string) (eventIDToTxnID map[string]string) { diff --git a/sync3/tracker.go b/sync3/tracker.go index 386d01c9..3a1c73cf 100644 --- a/sync3/tracker.go +++ b/sync3/tracker.go @@ -179,18 +179,6 @@ func (t *JoinedRoomsTracker) UsersInvitedToRoom(userIDs []string, roomID string) t.roomIDToInvitedUsers[roomID] = users } -func (t *JoinedRoomsTracker) IsUserInvited(userID, roomID string) bool { - t.mu.RLock() - defer t.mu.RUnlock() - users := t.roomIDToInvitedUsers[roomID] - for u := range users { - if u == userID { - return true - } - } - return false -} - func (t *JoinedRoomsTracker) NumInvitedUsersForRoom(roomID string) int { t.mu.RLock() defer t.mu.RUnlock() diff --git a/sync3/tracker_test.go b/sync3/tracker_test.go index 4df43361..7be2336a 100644 --- a/sync3/tracker_test.go +++ b/sync3/tracker_test.go @@ -45,10 +45,8 @@ func TestTracker(t *testing.T) { jrt.UsersInvitedToRoom([]string{"alice"}, "room4") assertNumEquals(t, jrt.NumInvitedUsersForRoom("room4"), 1) - assertBool(t, "expected alice to be invited", jrt.IsUserInvited("alice", "room4"), true) jrt.UserJoinedRoom("alice", "room4") assertNumEquals(t, jrt.NumInvitedUsersForRoom("room4"), 0) - assertBool(t, "expected alice to be not invited anymore", jrt.IsUserInvited("alice", "room4"), false) jrt.UserJoinedRoom("alice", "room4") // dupe joins don't bother it assertNumEquals(t, jrt.NumInvitedUsersForRoom("room4"), 0) jrt.UsersInvitedToRoom([]string{"bob"}, "room4") @@ -56,9 +54,6 @@ func TestTracker(t *testing.T) { jrt.UsersInvitedToRoom([]string{"bob"}, "room4") // dupe invites don't bother it assertNumEquals(t, jrt.NumInvitedUsersForRoom("room4"), 1) jrt.UserLeftRoom("bob", "room4") - assertNumEquals(t, jrt.NumInvitedUsersForRoom("room4"), 0) - - assertBool(t, "expected unknown user to be not invited", jrt.IsUserInvited("doesnotexist", "room3"), false) } func TestTrackerStartup(t *testing.T) {