Repository navigation
Add server announcement room configuration - #20353
anoadragon453 wants to merge 7 commits into
Conversation
Schema DiffPlease check that this looks as expected! common (sqlite)Unchanged common (postgres)Unchanged main (sqlite)main (postgres)state (sqlite)Unchanged state (postgres)Unchanged |
There was a problem hiding this comment.
schema/synapse-config.schema.yaml should have been updated instead, and then ./scripts-dev/gen_config_documentation.py schema/synapse-config.schema.yaml > docs/usage/configuration/config_documentation.md run to generate the md documentation.
| * `id` (string, required): A unique, nonempty configuration identifier. This is not | ||
| a Matrix room ID. Keep it stable: it maps the configuration entry to its existing | ||
| room, so changing the name, topic, avatar, or allowed users does not create a new | ||
| room. Changing `id` creates a new mapping rather than renaming the existing one. |
There was a problem hiding this comment.
| * `id` (string, required): A unique, nonempty configuration identifier. This is not | |
| a Matrix room ID. Keep it stable: it maps the configuration entry to its existing | |
| room, so changing the name, topic, avatar, or allowed users does not create a new | |
| room. Changing `id` creates a new mapping rather than renaming the existing one. | |
| * `id` (string, required): A unique, nonempty configuration identifier. This is not | |
| a Matrix room ID. It should not be changed after the associated room has been created. | |
| It maps the configuration entry to its existing | |
| room, so changing the name, topic, avatar, or allowed users does not create a new | |
| room. Changing `id` creates a new mapping rather than renaming the existing one. |
|
|
||
| Each entry is an object with the following options: | ||
|
|
||
| * `id` (string, required): A unique, nonempty configuration identifier. This is not |
There was a problem hiding this comment.
I guess when an announcement room is purged, the mapping should also be deleted.
| * `room_topic` (string|null): An optional topic for the room. Defaults to `null`. | ||
| * `room_avatar_url` (string|null): A valid `mxc://` URI for the **room** avatar. | ||
| Mutually exclusive with `room_avatar_path`. Defaults to `null`. | ||
| * `room_avatar_path` (string|null): A path to a local file to upload as the **room** |
There was a problem hiding this comment.
| * `room_avatar_path` (string|null): A path to a local file to upload as the **room** | |
| * `room_avatar_path` (string|null): A path to a local file to upload as the room |
| paths are resolved against the process's working directory. Files must be | ||
| readable by the **main process**, where uploads take place; they do not need to | ||
| be available on workers. Using this option requires |
There was a problem hiding this comment.
TODO: This is a concern. There's only ever one media worker. Why can't that worker upload the file?
|
|
||
| async def check_events( | ||
| self, requester: Requester, events_and_context: Sequence[EventPersistencePair] | ||
| ) -> None: |
There was a problem hiding this comment.
| ) -> None: | |
| ) -> None: | |
| """Check that one or more events may be sent in a local | |
| server announcement room. | |
| Prevent users other than those configured from sending events | |
| in the room. Also prevent any state events, as the rooms are managed by | |
| configuration. | |
| """ |
| # In particular, allow removed users to leave during cleanup. | ||
| # Matrix auth still checks whether the transition is valid. |
There was a problem hiding this comment.
| # In particular, allow removed users to leave during cleanup. | |
| # Matrix auth still checks whether the transition is valid. |
| if ( | ||
| event.sender != creator | ||
| and event.state_key == event.sender | ||
| and event.membership in (Membership.JOIN, Membership.LEAVE) | ||
| ): |
There was a problem hiding this comment.
| if ( | |
| event.sender != creator | |
| and event.state_key == event.sender | |
| and event.membership in (Membership.JOIN, Membership.LEAVE) | |
| ): | |
| # We need to allow users to join themselves so that we can generate | |
| # join events for allowed users. | |
| # | |
| # We need to allow users to leave themselves so that we can generate | |
| # leave events for users when purging an announcement room. | |
| # | |
| # In both cases, the homeserver is sending membership events on | |
| # behalf of users. | |
| if ( | |
| event.sender != creator | |
| and event.state_key == event.sender | |
| and event.membership in (Membership.JOIN, Membership.LEAVE) | |
| ): |
| """Cache an uploaded avatar for an existing announcement room mapping. | ||
|
|
||
| The caller supplies the file path, SHA-256 hex digest and uploaded MXC URI. |
There was a problem hiding this comment.
| """Cache an uploaded avatar for an existing announcement room mapping. | |
| The caller supplies the file path, SHA-256 hex digest and uploaded MXC URI. | |
| """Cache an uploaded avatar for an existing announcement room mapping. | |
| The sha256 hash allows one to check whether the file has changed on | |
| disk. |
| -- Mappings are retained even when announcements are removed from configuration. | ||
| -- There is deliberately no foreign key to rooms: these mappings must not block | ||
| -- normal room purges or disappear as a side effect of a purge. |
There was a problem hiding this comment.
Actually, I think we should purge mappings when a room is purged. What if someone messes up an announcement room and wants to start over but keep the same nice ID. They wouldn't have any way to do so other than editing the database by hand.
A better lifecycle would be:
- An administrator purges the announcement room.
- Purging also deletes its announcement mapping.
- On the next startup/reconciliation, an entry with that same id creates a new Matrix room and stores the new mapping.
If the administrator wants it gone permanently, they remove the configuration entry as well. If they want to start over, they keep it. That makes the config id identify the logical announcement room, rather than permanently binding it to one Matrix room ID.
e939ae4 to
59a39c5
Compare
|
Superseded by #20372 and a future PR. This PR ended up needing to be broken into smaller chunks. |
WIP
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.