summary refs log tree commit diff
path: root/synapse/storage/profile.py
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2017-11-30 01:17:15 +0000
committerMatthew Hodgson <matthew@matrix.org>2017-11-30 01:17:15 +0000
commita4bb133b6880c6adffce5feef3681504730cd484 (patch)
tree501acc1ed6ada420470ef2bf2452aaecb659ab4e /synapse/storage/profile.py
parentkick the user_directory index when new users register (diff)
downloadsynapse-a4bb133b6880c6adffce5feef3681504730cd484.tar.xz
fix thinkos galore
Diffstat (limited to 'synapse/storage/profile.py')
-rw-r--r--synapse/storage/profile.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py
index 484ad59b62..4e7b7c253b 100644
--- a/synapse/storage/profile.py
+++ b/synapse/storage/profile.py
@@ -16,6 +16,7 @@
 from twisted.internet import defer
 
 from synapse.storage.roommember import ProfileInfo
+from synapse.api.errors import StoreError
 
 from ._base import SQLBaseStore
 
@@ -28,16 +29,28 @@ class ProfileStore(SQLBaseStore):
             desc="create_profile",
         )
 
+    @defer.inlineCallbacks
     def get_profileinfo(self, user_localpart):
-        profile = self._simple_select_one(
-            table="profiles",
-            keyvalues={"user_id": user_localpart},
-            retcols=("displayname", "avatar_url"),
-            desc="get_profileinfo",
-        )
-        return ProfileInfo(
-            avatar_url=profile.avatar_url,
-            displayname=profile.displayname,
+        try:
+            profile = yield self._simple_select_one(
+                table="profiles",
+                keyvalues={"user_id": user_localpart},
+                retcols=("displayname", "avatar_url"),
+                desc="get_profileinfo",
+            )
+        except StoreError, 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):