From 8422a7f7f6154bcbadc52f0d0d27b8e6b989cb4c Mon Sep 17 00:00:00 2001
From: Patrick Cloke <clokep@users.noreply.github.com>
Date: Tue, 4 Jan 2022 11:08:08 -0500
Subject: [PATCH] Include the topic event in the prejoin state, per MSC3173.
 (#11666)

Invites and knocks will now include the topic in the stripped state
send to clients before joining the room.
---
 changelog.d/11666.feature                   | 1 +
 docs/sample_config.yaml                     | 1 +
 synapse/config/api.py                       | 2 ++
 tests/federation/transport/test_knocking.py | 9 +++++++++
 4 files changed, 13 insertions(+)
 create mode 100644 changelog.d/11666.feature

diff --git a/changelog.d/11666.feature b/changelog.d/11666.feature
new file mode 100644
index 0000000000..6f6b127e22
--- /dev/null
+++ b/changelog.d/11666.feature
@@ -0,0 +1 @@
+Include the room topic in the stripped state included with invites and knocking.
diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml
index 6696ed5d1e..00dfd2c013 100644
--- a/docs/sample_config.yaml
+++ b/docs/sample_config.yaml
@@ -1488,6 +1488,7 @@ room_prejoin_state:
    # - m.room.encryption
    # - m.room.name
    # - m.room.create
+   # - m.room.topic
    #
    # Uncomment the following to disable these defaults (so that only the event
    # types listed in 'additional_event_types' are shared). Defaults to 'false'.
diff --git a/synapse/config/api.py b/synapse/config/api.py
index b18044f982..25538b82d5 100644
--- a/synapse/config/api.py
+++ b/synapse/config/api.py
@@ -107,6 +107,8 @@ _DEFAULT_PREJOIN_STATE_TYPES = [
     EventTypes.Name,
     # Per MSC1772.
     EventTypes.Create,
+    # Per MSC3173.
+    EventTypes.Topic,
 ]
 
 
diff --git a/tests/federation/transport/test_knocking.py b/tests/federation/transport/test_knocking.py
index 663960ff53..bfa156eebb 100644
--- a/tests/federation/transport/test_knocking.py
+++ b/tests/federation/transport/test_knocking.py
@@ -108,6 +108,15 @@ class KnockingStrippedStateEventHelperMixin(TestCase):
                         "state_key": "",
                     },
                 ),
+                (
+                    EventTypes.Topic,
+                    {
+                        "content": {
+                            "topic": "A really cool room",
+                        },
+                        "state_key": "",
+                    },
+                ),
             ]
         )
 
-- 
GitLab