From f8420d6279e47b13c08036ead20207e39b6c4b19 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 1 Nov 2017 13:15:41 +0000 Subject: automatically set default displayname on register to avoid leaking ugly MXIDs and cluttering up the timeline with displayname changes as well as membership joins for autojoin rooms (e.g. the status autojoin rooms), automatically set the displayname to match the localpart of the mxid upon registration. --- synapse/rest/client/v2_alpha/register.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index d9a8cdbbb5..3f8f1d7f51 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 +from synapse.types import RoomID, RoomAlias, get_localpart_from_id 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,6 +343,13 @@ 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: -- cgit 1.4.1