summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2021-10-19 11:21:50 +0200
committerGitHub <noreply@github.com>2021-10-19 10:21:50 +0100
commitd85bc9a4a7c853c4ca0499f8c4e51d8644c3fcfa (patch)
treedf2beaec9e7642873db288e01be38f23c8ceb069
parentAdd missing type hints to synapse.api. (#11109) (diff)
downloadsynapse-d85bc9a4a7c853c4ca0499f8c4e51d8644c3fcfa.tar.xz
Include rejected status when we log events. (#11008)
If we find ourselves dealing with rejected events, we proably want to know
about it. Let's include it in the stringification of the event so that it gets
logged.
Diffstat (limited to '')
-rw-r--r--changelog.d/11008.misc1
-rw-r--r--synapse/events/__init__.py16
2 files changed, 11 insertions, 6 deletions
diff --git a/changelog.d/11008.misc b/changelog.d/11008.misc
new file mode 100644
index 0000000000..a67d95d66f
--- /dev/null
+++ b/changelog.d/11008.misc
@@ -0,0 +1 @@
+Include rejected status when we log events.
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 49190459c8..157669ea88 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -348,12 +348,16 @@ class EventBase(metaclass=abc.ABCMeta):
         return self.__repr__()
 
     def __repr__(self):
-        return "<%s event_id=%r, type=%r, state_key=%r, outlier=%s>" % (
-            self.__class__.__name__,
-            self.event_id,
-            self.get("type", None),
-            self.get("state_key", None),
-            self.internal_metadata.is_outlier(),
+        rejection = f"REJECTED={self.rejected_reason}, " if self.rejected_reason else ""
+
+        return (
+            f"<{self.__class__.__name__} "
+            f"{rejection}"
+            f"event_id={self.event_id}, "
+            f"type={self.get('type')}, "
+            f"state_key={self.get('state_key')}, "
+            f"outlier={self.internal_metadata.is_outlier()}"
+            ">"
         )