synapse/synapse
Quentin Gliech 4af33015af
Fix joining remote rooms when a `on_new_event` callback is registered (#16973)
Since Synapse 1.76.0, any module which registers a `on_new_event`
callback would brick the ability to join remote rooms.
This is because this callback tried to get the full state of the room,
which would end up in a deadlock.

Related:
https://github.com/matrix-org/synapse-auto-accept-invite/issues/18

The following module would brick the ability to join remote rooms:

```python
from typing import Any, Dict, Literal, Union
import logging

from synapse.module_api import ModuleApi, EventBase

logger = logging.getLogger(__name__)

class MyModule:
    def __init__(self, config: None, api: ModuleApi):
        self._api = api
        self._config = config

        self._api.register_third_party_rules_callbacks(
            on_new_event=self.on_new_event,
        )

    async def on_new_event(self, event: EventBase, _state_map: Any) -> None:
        logger.info(f"Received new event: {event}")

    @staticmethod
    def parse_config(_config: Dict[str, Any]) -> None:
        return None
```

This is technically a breaking change, as we are now passing partial
state on the `on_new_event` callback.
However, this callback was broken for federated rooms since 1.76.0, and
local rooms have full state anyway, so it's unlikely that it would
change anything.
2024-03-06 16:00:20 +01:00
..
_scripts Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
api Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
app Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
appservice Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
config Add a config to not send out device list updates for specific users (#16909) 2024-02-13 13:23:03 +00:00
crypto Only do one concurrent fetch per server in keyring (#16894) 2024-02-09 10:51:11 +00:00
events Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
federation Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
handlers Don't lock up when joining large rooms (#16903) 2024-02-20 14:29:18 +00:00
http Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
logging Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
media Bump lxml-stubs from 0.4.0 to 0.5.1 (#16885) 2024-02-06 09:29:17 +00:00
metrics Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
module_api Fix joining remote rooms when a `on_new_event` callback is registered (#16973) 2024-03-06 16:00:20 +01:00
push Revert "Improve DB performance of calculating badge counts for push. (#16756)" (#16979) 2024-03-05 12:27:27 +00:00
replication Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
res Use oEmbed for YouTube Shorts (#15025) 2023-05-03 12:54:42 -04:00
rest Accept unprefixed form of MSC3981 recurse parameter (#16842) 2024-02-06 09:48:39 +00:00
server_notices Merge remote-tracking branch 'gitlab/clokep/license-license' into new_develop 2023-12-13 15:11:56 +00:00
spam_checker_api Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
state Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
static Update link to the clients webpage, fix #15825 (#15874) 2023-07-06 17:28:09 +02:00
storage Fix joining remote rooms when a `on_new_event` callback is registered (#16973) 2024-03-06 16:00:20 +01:00
streams Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
synapse_rust Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
types Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
util Don't invalidate the entire event cache when we purge history (#16905) 2024-02-13 13:24:11 +00:00
__init__.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
_pydantic_compat.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
event_auth.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
notifier.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
py.typed Mark Module API error imports as re-exported and mark Synapse as containing type annotations (#11054) 2021-10-13 08:42:41 +01:00
server.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
visibility.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00