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

Commit

Permalink
Ensure synchrotrons can access is_support_user in the storage layer
Browse files Browse the repository at this point in the history
  • Loading branch information
neilisfragile committed Jan 2, 2019
1 parent 265513e commit 84b6fae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
1 change: 1 addition & 0 deletions changelog.d/4344.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix synchrotron exploding due to being unable to access is_support_user in storage layer
50 changes: 25 additions & 25 deletions synapse/storage/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,31 @@ def _query_for_auth(self, txn, token):

return None

@cachedInlineCallbacks()
def is_support_user(self, user_id):
"""Determines if the user is of type UserTypes.SUPPORT
Args:
user_id (str): user id to test
Returns:
Deferred[bool]: True if user is of type UserTypes.SUPPORT
"""
res = yield self.runInteraction(
"is_support_user", self.is_support_user_txn, user_id
)
defer.returnValue(res)

def is_support_user_txn(self, txn, user_id):
res = self._simple_select_one_onecol_txn(
txn=txn,
table="users",
keyvalues={"name": user_id},
retcol="user_type",
allow_none=True,
)
return True if res == UserTypes.SUPPORT else False


class RegistrationStore(RegistrationWorkerStore,
background_updates.BackgroundUpdateStore):
Expand Down Expand Up @@ -465,31 +490,6 @@ def is_guest(self, user_id):

defer.returnValue(res if res else False)

@cachedInlineCallbacks()
def is_support_user(self, user_id):
"""Determines if the user is of type UserTypes.SUPPORT
Args:
user_id (str): user id to test
Returns:
Deferred[bool]: True if user is of type UserTypes.SUPPORT
"""
res = yield self.runInteraction(
"is_support_user", self.is_support_user_txn, user_id
)
defer.returnValue(res)

def is_support_user_txn(self, txn, user_id):
res = self._simple_select_one_onecol_txn(
txn=txn,
table="users",
keyvalues={"name": user_id},
retcol="user_type",
allow_none=True,
)
return True if res == UserTypes.SUPPORT else False

@defer.inlineCallbacks
def user_add_threepid(self, user_id, medium, address, validated_at, added_at):
yield self._simple_upsert("user_threepids", {
Expand Down

0 comments on commit 84b6fae

Please sign in to comment.