diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-09 15:20:56 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-09 15:20:56 +0000 |
commit | 53557fc53259631d71055ef2ab8a6916b00d229b (patch) | |
tree | 208db19fb5bbcc5416e669bc496adc49acdcb1a7 /synapse/handlers/register.py | |
parent | Fix bugs so lazy room joining works as intended. (diff) | |
parent | Merge pull request #55 from matrix-org/profiling (diff) | |
download | synapse-53557fc53259631d71055ef2ab8a6916b00d229b.tar.xz |
Merge branch 'develop' into application-services
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 10ab9bc99e..7ed0ce6299 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -104,6 +104,23 @@ class RegistrationHandler(BaseHandler): raise RegistrationError( 500, "Cannot generate user ID.") + # create a default avatar for the user + # XXX: ideally clients would explicitly specify one, but given they don't + # and we want consistent and pretty identicons for random users, we'll + # do it here. + try: + auth_user = UserID.from_string(user_id) + identicon_resource = self.hs.get_resource_for_media_repository().getChildWithDefault("identicon", None) + upload_resource = self.hs.get_resource_for_media_repository().getChildWithDefault("upload", None) + identicon_bytes = identicon_resource.generate_identicon(user_id, 320, 320) + content_uri = yield upload_resource.create_content( + "image/png", None, identicon_bytes, len(identicon_bytes), auth_user + ) + profile_handler = self.hs.get_handlers().profile_handler + profile_handler.set_avatar_url(auth_user, auth_user, ("%s#auto" % content_uri)) + except NotImplementedError: + pass # make tests pass without messing around creating default avatars + defer.returnValue((user_id, token)) @defer.inlineCallbacks |