diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index 586f488f25..b043df68f5 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -3106,7 +3106,7 @@ class PersistEventsStore: txn, event, "content.topic", - get_plain_text_topic_from_event_content(event.content), + get_plain_text_topic_from_event_content(event.content) or "", ) def _store_room_name_txn(self, txn: LoggingTransaction, event: EventBase) -> None: diff --git a/synapse/util/events.py b/synapse/util/events.py index 4c609ad882..1e8f53c4e9 100644 --- a/synapse/util/events.py +++ b/synapse/util/events.py @@ -13,6 +13,8 @@ # # +from typing import Optional + from synapse.types import JsonDict from synapse.util.stringutils import random_string @@ -30,7 +32,7 @@ def generate_fake_event_id() -> str: return "$" + random_string(43) -def get_plain_text_topic_from_event_content(content: JsonDict): +def get_plain_text_topic_from_event_content(content: JsonDict) -> Optional[str]: """ Given the content of an m.room.topic event returns the plain text topic representation if any exists.