summary refs log tree commit diff
path: root/synapse/handlers/profile.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2018-04-17 10:28:00 +0100
committerDavid Baker <dave@matrix.org>2018-04-17 10:28:00 +0100
commit7285afa4be4f06b213c883ac3d1723742a7ca546 (patch)
tree42537f384cf943031e46e64dcd498b64c983bbc1 /synapse/handlers/profile.py
parentMerge remote-tracking branch 'origin/dinsic' into dbkr/profile_replication (diff)
downloadsynapse-7285afa4be4f06b213c883ac3d1723742a7ca546.tar.xz
Handle current batch number being null
Diffstat (limited to '')
-rw-r--r--synapse/handlers/profile.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index 12ab92ca85..d56adf069b 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,