Skip to content

Commit

Permalink
lint + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Jan 30, 2025
1 parent b0f804e commit 4e8dbd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ async def handle_new_client_event(
return prev_event

if event.type == "m.room.message" or event.type == "m.room.encrypted":
await self.store.set_room_participation(event.room_id, event.user_id)
await self.store.set_room_participation(event.user_id, event.room_id)

if event.internal_metadata.is_out_of_band_membership():
# the only sort of out-of-band-membership events we expect to see here are
Expand Down
5 changes: 3 additions & 2 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,15 +1705,16 @@ async def _populate_participant(self, progress: JsonDict, batch_size: int) -> in
"""
stream_token = progress.get("last_stream_token", None)

def _get_max_stream_token_txn(txn: LoggingTransaction) -> Optional[str]:
def _get_max_stream_token_txn(txn: LoggingTransaction) -> Optional[int]:
sql = """
SELECT event_stream_ordering from room_memberships
ORDER BY event_stream_ordering DESC
LIMIT 1;
"""
txn.execute(sql)
res = txn.fetchone()
assert res is not None
if not res:
return 0
return res[0]

def _background_populate_participant_txn(
Expand Down
8 changes: 4 additions & 4 deletions tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4102,7 +4102,7 @@ def test_sending_message_records_participation(self) -> None:

# user has not sent any messages, so should not be a participant
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
self.store.get_room_participation(self.user2, self.room1)
)
self.assertFalse(participant)

Expand All @@ -4117,7 +4117,7 @@ def test_sending_message_records_participation(self) -> None:
tok=self.tok2,
)
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
self.store.get_room_participation(self.user2, self.room1)
)
self.assertTrue(participant)

Expand All @@ -4130,7 +4130,7 @@ def test_sending_encrypted_event_records_participation(self) -> None:

# user has not sent any messages, so should not be a participant
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
self.store.get_room_participation(self.user2, self.room1)
)
self.assertFalse(participant)

Expand All @@ -4148,6 +4148,6 @@ def test_sending_encrypted_event_records_participation(self) -> None:
tok=self.tok2,
)
participant = self.get_success(
self.store.get_room_participation(self.room1, self.user2)
self.store.get_room_participation(self.user2, self.room1)
)
self.assertTrue(participant)

0 comments on commit 4e8dbd6

Please sign in to comment.