summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorAaron Raimist <aaron@raim.ist>2020-05-19 04:31:25 -0500
committerGitHub <noreply@github.com>2020-05-19 10:31:25 +0100
commit250f3eb991f129bbd12e4fce58a9d4124aabd41e (patch)
tree3eb92073fe50d2c4eeed3a917966fd664eaa3b83 /synapse/handlers/message.py
parentMerge tag 'v1.13.0rc3' into develop (diff)
downloadsynapse-250f3eb991f129bbd12e4fce58a9d4124aabd41e.tar.xz
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>
Diffstat (limited to '')
-rw-r--r--synapse/handlers/message.py8
1 files changed, 6 insertions, 2 deletions
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