From a11301179494f5a2924dcd60069c06f5c192020f Mon Sep 17 00:00:00 2001
From: Travis Ralston <travisr@matrix.org>
Date: Mon, 11 Jul 2022 07:12:28 -0600
Subject: [PATCH] Fix appservice EDUs failing to send if the EDU doesn't have a
 room ID (#13236)

* Fix appservice EDUs failing to send if the EDU doesn't have a room ID

As is in the case of presence.

* changelog

* linter

* fix linter again
---
 changelog.d/13236.bugfix        | 1 +
 synapse/appservice/scheduler.py | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 changelog.d/13236.bugfix

diff --git a/changelog.d/13236.bugfix b/changelog.d/13236.bugfix
new file mode 100644
index 0000000000..7fddc4413d
--- /dev/null
+++ b/changelog.d/13236.bugfix
@@ -0,0 +1 @@
+Fix appservices not receiving room-less EDUs, like presence, if enabled.
\ No newline at end of file
diff --git a/synapse/appservice/scheduler.py b/synapse/appservice/scheduler.py
index de5e5216c2..6c8695346f 100644
--- a/synapse/appservice/scheduler.py
+++ b/synapse/appservice/scheduler.py
@@ -319,7 +319,9 @@ class _ServiceQueuer:
         rooms_of_interesting_users.update(event.room_id for event in events)
         # EDUs
         rooms_of_interesting_users.update(
-            ephemeral["room_id"] for ephemeral in ephemerals
+            ephemeral["room_id"]
+            for ephemeral in ephemerals
+            if ephemeral.get("room_id") is not None
         )
 
         # Look up the AS users in those rooms
-- 
GitLab