forked-synapse/synapse/server_notices
Brendan Abolivier d73bf18d13
Server notices: Dissociate room creation/lookup from invite (#7199)
Fixes #6815

Before figuring out whether we should alert a user on MAU, we call get_notice_room_for_user to get some info on the existing server notices room for this user. This function, if the room doesn't exist, creates it and invites the user in it. This means that, if we decide later that no server notice is needed, the user gets invited in a room with no message in it. This happens at every restart of the server, since the room ID returned by get_notice_room_for_user is cached.

This PR fixes that by moving the inviting bit to a dedicated function, that's only called when the server actually needs to send a notice to the user. A potential issue with this approach is that the room that's created by get_notice_room_for_user doesn't match how that same function looks for an existing room (i.e. it creates a room that doesn't have an invite or a join for the current user in it, so it could lead to a new room being created each time a user syncs), but I'm not sure this is a problem given it's cached until the server restarts, so that function won't run very often.

It also renames get_notice_room_for_user into get_or_create_notice_room_for_user to make what it does clearer.
2020-04-04 17:27:45 +02:00
..
__init__.py Infrastructure for a server notices room 2018-05-17 17:58:25 +01:00
consent_server_notices.py Clean up newline quote marks around the codebase (#6362) 2019-11-21 12:00:14 +00:00
resource_limits_server_notices.py Server notices: Dissociate room creation/lookup from invite (#7199) 2020-04-04 17:27:45 +02:00
server_notices_manager.py Server notices: Dissociate room creation/lookup from invite (#7199) 2020-04-04 17:27:45 +02:00
server_notices_sender.py Run Black. (#5482) 2019-06-20 19:32:02 +10:00
worker_server_notices_sender.py Run Black. (#5482) 2019-06-20 19:32:02 +10:00