Omit displayname or avatar_url if they aren't set instead of returning null (#7497)
Per https://github.com/matrix-org/matrix-doc/issues/1436#issuecomment-410089470 they should be omitted instead of returning null or "". They aren't marked as required in the spec. Fixes https://github.com/matrix-org/synapse/issues/7333 Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
parent
ee421e5244
commit
250f3eb991
|
@ -0,0 +1 @@
|
||||||
|
When sending `m.room.member` events, omit `displayname` and `avatar_url` if they aren't set instead of setting them to `null`. Contributed by Aaron Raimist.
|
|
@ -484,9 +484,13 @@ class EventCreationHandler(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if "displayname" not in content:
|
if "displayname" not in content:
|
||||||
content["displayname"] = yield profile.get_displayname(target)
|
displayname = yield profile.get_displayname(target)
|
||||||
|
if displayname is not None:
|
||||||
|
content["displayname"] = displayname
|
||||||
if "avatar_url" not in content:
|
if "avatar_url" not in content:
|
||||||
content["avatar_url"] = yield profile.get_avatar_url(target)
|
avatar_url = yield profile.get_avatar_url(target)
|
||||||
|
if avatar_url is not None:
|
||||||
|
content["avatar_url"] = avatar_url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Failed to get profile information for %r: %s", target, e
|
"Failed to get profile information for %r: %s", target, e
|
||||||
|
|
Loading…
Reference in New Issue