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

Commit

Permalink
Pull is_guest up into the RegistrationWorkerStore
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Mar 24, 2022
1 parent 9daa8d3 commit 7aa5b84
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,18 @@ def _replace_refresh_token_txn(txn: LoggingTransaction) -> None:
"replace_refresh_token", _replace_refresh_token_txn
)

@cached()
async def is_guest(self, user_id: str) -> bool:
res = await self.db_pool.simple_select_one_onecol(
table="users",
keyvalues={"name": user_id},
retcol="is_guest",
allow_none=True,
desc="is_guest",
)

return res if res else False


class RegistrationBackgroundUpdateStore(RegistrationWorkerStore):
def __init__(
Expand Down Expand Up @@ -1886,18 +1898,6 @@ def set_user_deactivated_status_txn(self, txn, user_id: str, deactivated: bool):
self._invalidate_cache_and_stream(txn, self.get_user_by_id, (user_id,))
txn.call_after(self.is_guest.invalidate, (user_id,))

@cached()
async def is_guest(self, user_id: str) -> bool:
res = await self.db_pool.simple_select_one_onecol(
table="users",
keyvalues={"name": user_id},
retcol="is_guest",
allow_none=True,
desc="is_guest",
)

return res if res else False


class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
def __init__(
Expand Down

0 comments on commit 7aa5b84

Please sign in to comment.