Back out change preventing setting null avatar URLs

This commit is contained in:
Erik Johnston 2019-12-11 11:46:55 +00:00
parent d21577bdcb
commit 72acca6a32
2 changed files with 7 additions and 7 deletions

View File

@ -1 +1 @@
Fix error message when setting your profile's avatar URL mentioning displaynames, and prevent NoneType avatar_urls. Fix incorrect error message for invalid requests when setting user's avatar URL.

View File

@ -15,6 +15,7 @@
""" This module contains REST servlets to do with profile: /profile/<paths> """ """ This module contains REST servlets to do with profile: /profile/<paths> """
from synapse.api.errors import Codes, SynapseError
from synapse.http.servlet import RestServlet, parse_json_object_from_request from synapse.http.servlet import RestServlet, parse_json_object_from_request
from synapse.rest.client.v2_alpha._base import client_patterns from synapse.rest.client.v2_alpha._base import client_patterns
from synapse.types import UserID from synapse.types import UserID
@ -103,12 +104,11 @@ class ProfileAvatarURLRestServlet(RestServlet):
content = parse_json_object_from_request(request) content = parse_json_object_from_request(request)
try: try:
new_avatar_url = content.get("avatar_url") new_avatar_url = content["avatar_url"]
except Exception: except KeyError:
return 400, "Unable to parse avatar_url" raise SynapseError(
400, "Missing key 'avatar_url'", errcode=Codes.MISSING_PARAM
if new_avatar_url is None: )
return 400, "Missing required key: avatar_url"
await self.profile_handler.set_avatar_url( await self.profile_handler.set_avatar_url(
user, requester, new_avatar_url, is_admin user, requester, new_avatar_url, is_admin