diff --git a/mautrix_facebook/user.py b/mautrix_facebook/user.py index e0c6a8b0aaf4ff253e70e389fed076e429616dcd..f50a6f74f1a70346114e52adef03346c85fb6bc7 100644 --- a/mautrix_facebook/user.py +++ b/mautrix_facebook/user.py @@ -48,6 +48,7 @@ class User(BaseUser): notice_room: RoomID _notice_room_lock: asyncio.Lock + _notice_send_lock: asyncio.Lock is_admin: bool permission_level: str _is_logged_in: Optional[bool] @@ -69,6 +70,7 @@ class User(BaseUser): self.mxid = mxid self.notice_room = notice_room self._notice_room_lock = asyncio.Lock() + self._notice_send_lock = asyncio.Lock() self.by_mxid[mxid] = self self.command_status = None self.is_whitelisted, self.is_admin, self.permission_level = config.get_permissions(mxid) @@ -409,7 +411,9 @@ class User(BaseUser): else MessageType.NOTICE)) if edit: content.set_edit(edit) - event_id = await self.az.intent.send_message(await self.get_notice_room(), content) + # This is locked to prevent notices going out in the wrong order + async with self._notice_send_lock: + event_id = await self.az.intent.send_message(await self.get_notice_room(), content) except Exception: self.log.warning("Failed to send bridge notice", exc_info=True) return edit or event_id diff --git a/requirements.txt b/requirements.txt index f3fbb4bfc9ffdffbc523437f913e07c3f9b3dd17..cd396017b90c81b907d67c39a65e9a846370b369 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ alembic>=1,<2 ruamel.yaml>=0.15.94,<0.17 commonmark>=0.8,<0.10 python-magic>=0.4,<0.5 -mautrix==0.5.0 +mautrix==0.5.1 fbchat-asyncio==0.6.0b2