summary refs log tree commit diff
path: root/synapse/handlers/profile.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/handlers/profile.py')
-rw-r--r--synapse/handlers/profile.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py

index a9c76f323e..91418fb83e 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py
@@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2014-2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -99,10 +100,10 @@ class ProfileHandler(BaseHandler): logger.info("Replicating profile batch %d to %s", batchnum, host) batch_rows = yield self.store.get_profile_batch(batchnum) batch = { - UserID(r["user_id"], self.hs.hostname).to_string(): { + UserID(r["user_id"], self.hs.hostname).to_string(): ({ "display_name": r["displayname"], "avatar_url": r["avatar_url"], - } for r in batch_rows + } if r["active"] else None) for r in batch_rows } url = "https://%s/_matrix/identity/api/v1/replicate_profiles" % (host,) @@ -246,6 +247,27 @@ class ProfileHandler(BaseHandler): run_in_background(self._replicate_profiles) @defer.inlineCallbacks + def set_active(self, target_user, active): + """ + Sets the 'active' flag on a user profile. If set to false, the user account is + considered deactivated. + Note that unlike set_displayname and set_avatar_url, this does *not* perform + authorization checks! This is because the only place it's used currently is + in account deactivation where we've already done these checks anyway. + """ + if len(self.hs.config.replicate_user_profiles_to) > 0: + cur_batchnum = yield self.store.get_latest_profile_replication_batch_number() + new_batchnum = 0 if cur_batchnum is None else cur_batchnum + 1 + else: + new_batchnum = None + yield self.store.set_profile_active( + target_user.localpart, active, new_batchnum + ) + + # start a profile replication push + run_in_background(self._replicate_profiles) + + @defer.inlineCallbacks def get_avatar_url(self, target_user): if self.hs.is_mine(target_user): avatar_url = yield self.store.get_profile_avatar_url(