summary refs log tree commit diff
diff options
context:
space:
mode:
authorSorunome <mail@sorunome.de>2020-07-10 19:44:56 +0200
committerGitHub <noreply@github.com>2020-07-10 18:44:56 +0100
commit1bca21e1da3853d64561d39eea8b487db378ce22 (patch)
treed79550290d3ab18033113ffa577f6df5a9731238
parentMerge branch 'release-v1.17.0' into develop (diff)
downloadsynapse-1bca21e1da3853d64561d39eea8b487db378ce22.tar.xz
Include room states on invite events sent to ASes (#6455)
-rw-r--r--changelog.d/6455.feature1
-rw-r--r--synapse/appservice/api.py20
2 files changed, 17 insertions, 4 deletions
diff --git a/changelog.d/6455.feature b/changelog.d/6455.feature
new file mode 100644
index 0000000000..eb286cb70f
--- /dev/null
+++ b/changelog.d/6455.feature
@@ -0,0 +1 @@
+Include room states on invite events that are sent to application services. Contributed by @Sorunome.
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index f92bfb420b..1e0e4d497d 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -19,7 +19,7 @@ from prometheus_client import Counter
 
 from twisted.internet import defer
 
-from synapse.api.constants import ThirdPartyEntityKind
+from synapse.api.constants import EventTypes, ThirdPartyEntityKind
 from synapse.api.errors import CodeMessageException
 from synapse.events.utils import serialize_event
 from synapse.http.client import SimpleHttpClient
@@ -207,7 +207,7 @@ class ApplicationServiceApi(SimpleHttpClient):
         if service.url is None:
             return True
 
-        events = self._serialize(events)
+        events = self._serialize(service, events)
 
         if txn_id is None:
             logger.warning(
@@ -233,6 +233,18 @@ class ApplicationServiceApi(SimpleHttpClient):
         failed_transactions_counter.labels(service.id).inc()
         return False
 
-    def _serialize(self, events):
+    def _serialize(self, service, events):
         time_now = self.clock.time_msec()
-        return [serialize_event(e, time_now, as_client_event=True) for e in events]
+        return [
+            serialize_event(
+                e,
+                time_now,
+                as_client_event=True,
+                is_invite=(
+                    e.type == EventTypes.Member
+                    and e.membership == "invite"
+                    and service.is_interested_in_user(e.state_key)
+                ),
+            )
+            for e in events
+        ]