-
Notifications
You must be signed in to change notification settings - Fork 421
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
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c323dc1
Add plain-text handling for rich-text topics as per MSC3765
Johennes 42c5182
Add changelog
Johennes 4dbca25
Appease the linter
Johennes 64012ba
Add comment to explain default mimetype
Johennes 00d0607
Extract constants for accessing m.room.topic fields
Johennes 759f4fe
Explain that we prefer m.topic over topic when extracting the plain text
Johennes efd05b7
Skip invalid plain text representations and scrutinise body
Johennes 174bc8f
Read plain text representation if available when reindexing search
Johennes 1ca087f
Wrap comment
Johennes 5471c32
Improve comment
Johennes ea45ecd
Add doc string for args
Johennes 2059b64
Switch to use pydantic models for parsing topic event contents
Johennes 00d88c1
Fix type annotations
Johennes 39dfb69
Fix type annotations _again_
Johennes eb0a3d2
Merge branch 'develop' into johannes/msc3765
MadLittleMods 3146ec1
Add doc comments
MadLittleMods b081611
Use `ParseModel` in other spots
MadLittleMods 2296cea
Update comment with `text/plain` marked as value
MadLittleMods 94296f9
Simpler pattern to pick first `text/plain` representation
MadLittleMods 8c6d776
Merge branch 'develop' into johannes/msc3765
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add plain-text handling for rich-text topics as per [MSC3765](https://github.com/matrix-org/matrix-spec-proposals/pull/3765). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # | ||
| # This file is licensed under the Affero General Public License (AGPL) version 3. | ||
| # | ||
| # Copyright (C) 2024 New Vector, Ltd | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License as | ||
| # published by the Free Software Foundation, either version 3 of the | ||
| # License, or (at your option) any later version. | ||
| # | ||
| # See the GNU Affero General Public License for more details: | ||
| # <https://www.gnu.org/licenses/agpl-3.0.html>. | ||
| # | ||
| # | ||
|
|
||
| from synapse._pydantic_compat import BaseModel, Extra | ||
|
|
||
|
|
||
| class ParseModel(BaseModel): | ||
Johennes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """A custom version of Pydantic's BaseModel which | ||
| - ignores unknown fields and | ||
| - does not allow fields to be overwritten after construction, | ||
| but otherwise uses Pydantic's default behaviour. | ||
| For now, ignore unknown fields. In the future, we could change this so that unknown | ||
| config values cause a ValidationError, provided the error messages are meaningful to | ||
| server operators. | ||
| Subclassing in this way is recommended by | ||
| https://pydantic-docs.helpmanual.io/usage/model_config/#change-behaviour-globally | ||
| """ | ||
|
|
||
| class Config: | ||
| # By default, ignore fields that we don't recognise. | ||
| extra = Extra.ignore | ||
| # By default, don't allow fields to be reassigned after parsing. | ||
| allow_mutation = False | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.