Handle current batch number being null

This commit is contained in:
David Baker 2018-04-17 10:28:00 +01:00
parent 3c446d0a81
commit 7285afa4be

View File

@ -212,7 +212,8 @@ class ProfileHandler(BaseHandler):
if new_displayname == '': if new_displayname == '':
new_displayname = None 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( yield self.store.set_profile_displayname(
target_user.localpart, new_displayname, new_batchnum target_user.localpart, new_displayname, new_batchnum
@ -267,7 +268,8 @@ class ProfileHandler(BaseHandler):
if not by_admin and target_user != requester.user: if not by_admin and target_user != requester.user:
raise AuthError(400, "Cannot set another user's avatar_url") 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( yield self.store.set_profile_avatar_url(
target_user.localpart, new_avatar_url, new_batchnum, target_user.localpart, new_avatar_url, new_batchnum,