Skip to content

Add plain-text handling for rich-text topics as per MSC3765 #18195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 9, 2025

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Feb 28, 2025

This implements matrix-org/matrix-spec-proposals#3765 which is already merged and, therefore, can use stable identifiers.

For /publicRooms and /hierarchy, the topic is read from the eponymous field of the current_state_events table. Rather than introduce further columns in this table, I changed the insertion / update logic to write the plain-text topic from the rich topic into the existing field. This will not take effect for existing rooms unless their topic is changed. However, existing rooms shouldn't have rich topics to begin with.

Similarly, for server-side search, I changed the insertion logic of the event_search table to prefer the value from the rich topic. Again, existing events shouldn't have rich topics and, therefore, don't need to be migrated in the table.

Spec doc: https://spec.matrix.org/v1.15/client-server-api/#mroomtopic

Part of supporting Matrix v1.15: https://spec.matrix.org/v1.15/client-server-api/#mroomtopic

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

@Johennes Johennes marked this pull request as ready for review February 28, 2025 10:01
@Johennes Johennes requested a review from a team as a code owner February 28, 2025 10:01
@CLAassistant
Copy link

CLAassistant commented Mar 23, 2025

CLA assistant check
All committers have signed the CLA.

@@ -757,6 +757,59 @@ def test_post_room_initial_state(self) -> None:
assert channel.resource_usage is not None
self.assertEqual(37, channel.resource_usage.db_txn_count)

def test_post_room_topic(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would benefit more if we converted this to a set of Complement tests that any homeserver implementation could test against.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I've opened matrix-org/complement#788 for this. Do you want me to remove the tests here in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave them here ⏩

@Johennes
Copy link
Contributor Author

Johennes commented Jul 8, 2025

All comments except for the Complement tests addressed.

I haven't used pydantic before so this part is most probably utter crap. 🙈

Pydantic v2 has an OnErrorOmit which would simplify a few things but if I'm reading things correctly, we don't use v2 consistently.

Copy link
Contributor

@MadLittleMods MadLittleMods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to go. Just want to have you look at my changes before shipping to ensure I'm not overlooking something.

@Johennes
Copy link
Contributor Author

Johennes commented Jul 9, 2025

I think this is good to go. Just want to have you look at my changes before shipping to ensure I'm not overlooking something.

Thanks and sorry you had to patch my mess up yourself.

@@ -757,6 +757,59 @@ def test_post_room_initial_state(self) -> None:
assert channel.resource_usage is not None
self.assertEqual(37, channel.resource_usage.db_txn_count)

def test_post_room_topic(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave them here ⏩

@MadLittleMods MadLittleMods merged commit b9b8775 into element-hq:develop Jul 9, 2025
39 checks passed
@MadLittleMods
Copy link
Contributor

Thanks for the contribution and being willing to jump to robust Pydantic parsing @Johennes 🐏

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Aug 7, 2025
Tested on NetBSD 9 amd64 (federation, multiple clients)

# Synapse 1.135.0 (2025-08-01)

## Features

- Add `recaptcha_private_key_path` and `recaptcha_public_key_path` config option. ([\#17984](element-hq/synapse#17984), [\#18684](element-hq/synapse#18684))
- Add plain-text handling for rich-text topics as per [MSC3765](matrix-org/matrix-spec-proposals#3765). ([\#18195](element-hq/synapse#18195))
- If enabled by the user, server admins will see [soft failed](https://spec.matrix.org/v1.13/server-server-api/#soft-failure) events over the Client-Server API. ([\#18238](element-hq/synapse#18238))
- Add experimental support for [MSC4277: Harmonizing the reporting endpoints](matrix-org/matrix-spec-proposals#4277). ([\#18263](element-hq/synapse#18263))
- Add ability to limit amount of media uploaded by a user in a given time period. ([\#18527](element-hq/synapse#18527))
- Enable workers to write directly to the device lists stream and handle device list updates, reducing load on the main process. ([\#18581](element-hq/synapse#18581))
- Support arbitrary profile fields. Contributed by @clokep. ([\#18635](element-hq/synapse#18635))
- Advertise support for Matrix v1.12. ([\#18647](element-hq/synapse#18647))
- Add an option to issue redactions as an admin user via the [admin redaction endpoint](https://element-hq.github.io/synapse/latest/admin_api/user_admin_api.html#redact-all-the-events-of-a-user). ([\#18671](element-hq/synapse#18671))
- Add experimental and incomplete support for [MSC4306: Thread Subscriptions](https://github.com/matrix-org/matrix-spec-proposals/blob/rei/msc_thread_subscriptions/proposals/4306-thread-subscriptions.md). ([\#18674](element-hq/synapse#18674))
- Include `event_id` when getting state with `?format=event`. Contributed by @tulir @ Beeper. ([\#18675](element-hq/synapse#18675))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants