From 7285afa4be4f06b213c883ac3d1723742a7ca546 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 17 Apr 2018 10:28:00 +0100 Subject: [PATCH] Handle current batch number being null --- synapse/handlers/profile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index 12ab92ca8..d56adf069 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -212,7 +212,8 @@ class ProfileHandler(BaseHandler): if new_displayname == '': new_displayname = None - new_batchnum = (yield self.store.get_latest_profile_replication_batch_number()) + 1 + cur_batchnum = yield self.store.get_latest_profile_replication_batch_number() + new_batchnum = 0 if cur_batchnum is None else cur_batchnum + 1 yield self.store.set_profile_displayname( target_user.localpart, new_displayname, new_batchnum @@ -267,7 +268,8 @@ class ProfileHandler(BaseHandler): if not by_admin and target_user != requester.user: raise AuthError(400, "Cannot set another user's avatar_url") - new_batchnum = yield self.store.get_latest_profile_replication_batch_number() + 1 + cur_batchnum = yield self.store.get_latest_profile_replication_batch_number() + new_batchnum = 0 if cur_batchnum is None else cur_batchnum + 1 yield self.store.set_profile_avatar_url( target_user.localpart, new_avatar_url, new_batchnum,