Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel committed May 12, 2022
1 parent 467b136 commit 632ee75
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,11 @@ async def current_sync_for_user(
set_tag(SynapseTags.SYNC_RESULT, bool(sync_result))
return sync_result

async def push_rules_for_user(self, user: UserID) -> JsonDict:
async def push_rules_for_user(self, user: UserID) -> Dict[str, Dict[str, list]]:
user_id = user.to_string()
rules = await self.store.get_push_rules_for_user(user_id)
rules = format_push_rules_for_user(user, rules)
return rules
result = format_push_rules_for_user(user, rules)
return result

async def ephemeral_by_room(
self,
Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _count_messages(txn: LoggingTransaction) -> int:
"""

txn.execute(sql, (like_clause, self.stream_ordering_day_ago))
(count,) = txn.fetchone()
(count,) = cast(Tuple[int], txn.fetchone())
return count

return await self.db_pool.runInteraction(
Expand Down Expand Up @@ -189,7 +189,7 @@ def _count_messages(txn: LoggingTransaction) -> int:
"""

txn.execute(sql, (like_clause, self.stream_ordering_day_ago))
(count,) = txn.fetchone()
(count,) = cast(Tuple[int], txn.fetchone())
return count

return await self.db_pool.runInteraction(
Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def have_push_rules_changed_txn(txn: LoggingTransaction) -> bool:
" WHERE user_id = ? AND ? < stream_id"
)
txn.execute(sql, (user_id, last_id))
(count,) = txn.fetchone()
(count,) = cast(Tuple[int], txn.fetchone())
return bool(count)

return await self.db_pool.runInteraction(
Expand Down Expand Up @@ -345,7 +345,7 @@ async def get_all_push_rule_updates(
return [], current_id, False

def get_all_push_rule_updates_txn(
txn: LoggingTransaction
txn: LoggingTransaction,
) -> Tuple[List[Tuple[int, tuple]], int, bool]:
sql = """
SELECT stream_id, user_id
Expand Down
16 changes: 7 additions & 9 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
ProfileInfo,
RoomsForUser,
)
from synapse.types import JsonDict, PersistedEventPosition, StateMap, get_domain_from_id
from synapse.types import PersistedEventPosition, StateMap, get_domain_from_id
from synapse.util.async_helpers import Linearizer
from synapse.util.caches import intern_string
from synapse.util.caches.descriptors import _CacheContext, cached, cachedList
Expand Down Expand Up @@ -189,9 +189,7 @@ async def get_users_in_room(self, room_id: str) -> List[str]:
"get_users_in_room", self.get_users_in_room_txn, room_id
)

def get_users_in_room_txn(
self, txn: LoggingTransaction, room_id: str
) -> List[str]:
def get_users_in_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[str]:
# If we can assume current_state_events.membership is up to date
# then we can avoid a join, which is a Very Good Thing given how
# frequently this function gets called.
Expand Down Expand Up @@ -232,7 +230,7 @@ async def get_users_in_room_with_profiles(
"""

def _get_users_in_room_with_profiles(
txn: LoggingTransaction
txn: LoggingTransaction,
) -> Dict[str, ProfileInfo]:
sql = """
SELECT state_key, display_name, avatar_url FROM room_memberships as m
Expand Down Expand Up @@ -672,7 +670,7 @@ async def get_users_who_share_room_with_user(
async def get_joined_users_from_context(
self, event: EventBase, context: EventContext
) -> Dict[str, ProfileInfo]:
state_group: Union[object, Optional[int]] = context.state_group
state_group = context.state_group
if not state_group:
# If state_group is None it means it has yet to be assigned a
# state group, i.e. we need to make sure that calls with a state_group
Expand Down Expand Up @@ -1271,9 +1269,9 @@ def _background_current_state_membership_txn(


class RoomMemberStore(
RoomMemberWorkerStore,
RoomMemberBackgroundUpdateStore,
CacheInvalidationWorkerStore,
RoomMemberWorkerStore,
RoomMemberBackgroundUpdateStore,
CacheInvalidationWorkerStore,
):
def __init__(
self,
Expand Down

0 comments on commit 632ee75

Please sign in to comment.