summary refs log tree commit diff
path: root/synapse/handlers/profile.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-08-25 16:48:58 +0100
committerGitHub <noreply@github.com>2017-08-25 16:48:58 +0100
commit7f0d0ba3bcd3aa56cab0d16346e99ed6a60cc9eb (patch)
tree62e646b2c99919f1acb2c4eb21d25d4dd701685a /synapse/handlers/profile.py
parentMerge pull request #2429 from matrix-org/erikj/groups_profile_cache (diff)
parentAdd user profiles to summary from group server (diff)
downloadsynapse-7f0d0ba3bcd3aa56cab0d16346e99ed6a60cc9eb.tar.xz
Merge pull request #2430 from matrix-org/erikj/groups_profile_cache
Add user profiles to summary from group server
Diffstat (limited to 'synapse/handlers/profile.py')
-rw-r--r--synapse/handlers/profile.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index c3cee38a43..e56e0a52bf 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -72,6 +72,29 @@ class ProfileHandler(BaseHandler):
                 raise
 
     @defer.inlineCallbacks
+    def get_profile_from_cache(self, user_id):
+        """Get the profile information from our local cache. If the user is
+        ours then the profile information will always be corect. Otherwise,
+        it may be out of date/missing.
+        """
+        target_user = UserID.from_string(user_id)
+        if self.hs.is_mine(target_user):
+            displayname = yield self.store.get_profile_displayname(
+                target_user.localpart
+            )
+            avatar_url = yield self.store.get_profile_avatar_url(
+                target_user.localpart
+            )
+
+            defer.returnValue({
+                "displayname": displayname,
+                "avatar_url": avatar_url,
+            })
+        else:
+            profile = yield self.store.get_from_remote_profile_cache(user_id)
+            defer.returnValue(profile or {})
+
+    @defer.inlineCallbacks
     def get_displayname(self, target_user):
         if self.hs.is_mine(target_user):
             displayname = yield self.store.get_profile_displayname(