summary refs log tree commit diff
path: root/synapse/groups
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-08-25 11:21:34 +0100
committerErik Johnston <erik@matrix.org>2017-08-25 11:25:47 +0100
commit27ebc5c8f299488ccc0a6f100ec3b248cd81a058 (patch)
tree218364141a9e880894e9a9245f3fafc47e0a6e21 /synapse/groups
parentAdd _simple_update (diff)
downloadsynapse-27ebc5c8f299488ccc0a6f100ec3b248cd81a058.tar.xz
Add remote profile cache
Diffstat (limited to 'synapse/groups')
-rw-r--r--synapse/groups/groups_server.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py
index f25f327eb9..6bccae4bfb 100644
--- a/synapse/groups/groups_server.py
+++ b/synapse/groups/groups_server.py
@@ -503,6 +503,13 @@ class GroupsServerHandler(object):
                 get_domain_from_id(user_id), group_id, user_id, content
             )
 
+            user_profile = res.get("user_profile", {})
+            yield self.store.add_remote_profile_cache(
+                user_id,
+                displayname=user_profile.get("displayname"),
+                avatar_url=user_profile.get("avatar_url"),
+            )
+
         if res["state"] == "join":
             if not self.hs.is_mine_id(user_id):
                 remote_attestation = res["attestation"]
@@ -627,6 +634,9 @@ class GroupsServerHandler(object):
                     get_domain_from_id(user_id), group_id, user_id, {}
                 )
 
+        if not self.hs.is_mine_id(user_id):
+            yield self.store.maybe_delete_remote_profile_cache(user_id)
+
         defer.returnValue({})
 
     @defer.inlineCallbacks
@@ -647,6 +657,7 @@ class GroupsServerHandler(object):
         avatar_url = profile.get("avatar_url")
         short_description = profile.get("short_description")
         long_description = profile.get("long_description")
+        user_profile = content.get("user_profile", {})
 
         yield self.store.create_group(
             group_id,
@@ -679,6 +690,13 @@ class GroupsServerHandler(object):
             remote_attestation=remote_attestation,
         )
 
+        if not self.hs.is_mine_id(user_id):
+            yield self.store.add_remote_profile_cache(
+                user_id,
+                displayname=user_profile.get("displayname"),
+                avatar_url=user_profile.get("avatar_url"),
+            )
+
         defer.returnValue({
             "group_id": group_id,
         })