diff options
-rw-r--r-- | changelog.d/7497.bugfix | 1 | ||||
-rw-r--r-- | synapse/handlers/message.py | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.d/7497.bugfix b/changelog.d/7497.bugfix new file mode 100644 index 0000000000..3c7920cb10 --- /dev/null +++ b/changelog.d/7497.bugfix @@ -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. diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 0242521cc6..8f362896a2 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -484,9 +484,13 @@ class EventCreationHandler(object): 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 |