Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Omit displayname or avatar_url if they aren't set instead of returnin…
Browse files Browse the repository at this point in the history
…g 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 #7333

Signed-off-by: Aaron Raimist <aaron@raim.ist>
  • Loading branch information
aaronraimist authored May 19, 2020
1 parent ee421e5 commit 250f3eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/7497.bugfix
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 6 additions & 2 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,13 @@ def create_event(

try:
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:
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:
logger.info(
"Failed to get profile information for %r: %s", target, e
Expand Down

0 comments on commit 250f3eb

Please sign in to comment.