diff options
author | Matthew Hodgson <matthew@matrix.org> | 2017-11-01 15:51:25 +0000 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2017-11-01 15:51:30 +0000 |
commit | 9f7a555b4e8c1d90a638365cf1d4acb3ce7f3db7 (patch) | |
tree | 6873a112a7a90c163a6687fcb3728a4b7e2342f8 /synapse | |
parent | automatically set default displayname on register (diff) | |
download | synapse-9f7a555b4e8c1d90a638365cf1d4acb3ce7f3db7.tar.xz |
switch to setting default displayname in the storage layer
to avoid clobbering guest user displaynames on registration
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 9 | ||||
-rw-r--r-- | synapse/storage/registration.py | 6 |
2 files changed, 5 insertions, 10 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index 3f8f1d7f51..d9a8cdbbb5 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -20,7 +20,7 @@ import synapse import synapse.types from synapse.api.auth import get_access_token_from_request, has_access_token from synapse.api.constants import LoginType -from synapse.types import RoomID, RoomAlias, get_localpart_from_id +from synapse.types import RoomID, RoomAlias from synapse.api.errors import SynapseError, Codes, UnrecognizedRequestError from synapse.http.servlet import ( RestServlet, parse_json_object_from_request, assert_params_in_request, parse_string @@ -343,13 +343,6 @@ class RegisterRestServlet(RestServlet): generate_token=False, ) - # before we auto-join, set a default displayname to avoid ugly race - # between the client joining rooms and trying to set a displayname - localpart = get_localpart_from_id(registered_user_id) - yield self.store.set_profile_displayname( - localpart, localpart - ) - # auto-join the user to any rooms we're supposed to dump them into fake_requester = synapse.types.create_requester(registered_user_id) for r in self.hs.config.auto_join_rooms: diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index 20acd58fcf..3442af4b90 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -177,9 +177,11 @@ class RegistrationStore(background_updates.BackgroundUpdateStore): ) if create_profile_with_localpart: + # set a default displayname serverside to avoid ugly race + # between auto-joins and clients trying to set displaynames txn.execute( - "INSERT INTO profiles(user_id) VALUES (?)", - (create_profile_with_localpart,) + "INSERT INTO profiles(user_id, displayname) VALUES (?,?)", + (create_profile_with_localpart, create_profile_with_localpart) ) self._invalidate_cache_and_stream( |