diff options
author | Erik Johnston <erik@matrix.org> | 2017-12-07 14:24:01 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-12-07 14:24:01 +0000 |
commit | d8a6c734fa1ab6681431c43885ced627e5e672e0 (patch) | |
tree | 4ba6a510997e38e829c6a6b0aa53caace4e7b872 /synapse/storage/profile.py | |
parent | Copy dict in update_membership too (diff) | |
parent | Merge pull request #2723 from matrix-org/matthew/search-all-local-users (diff) | |
download | synapse-d8a6c734fa1ab6681431c43885ced627e5e672e0.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/createroom_content
Diffstat (limited to 'synapse/storage/profile.py')
-rw-r--r-- | synapse/storage/profile.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index beea3102fc..ec02e73bc2 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -15,6 +15,9 @@ from twisted.internet import defer +from synapse.storage.roommember import ProfileInfo +from synapse.api.errors import StoreError + from ._base import SQLBaseStore @@ -26,6 +29,30 @@ class ProfileStore(SQLBaseStore): desc="create_profile", ) + @defer.inlineCallbacks + def get_profileinfo(self, user_localpart): + try: + profile = yield self._simple_select_one( + table="profiles", + keyvalues={"user_id": user_localpart}, + retcols=("displayname", "avatar_url"), + desc="get_profileinfo", + ) + except StoreError as e: + if e.code == 404: + # no match + defer.returnValue(ProfileInfo(None, None)) + return + else: + raise + + defer.returnValue( + ProfileInfo( + avatar_url=profile['avatar_url'], + display_name=profile['displayname'], + ) + ) + def get_profile_displayname(self, user_localpart): return self._simple_select_one_onecol( table="profiles", |