Skip to content
Snippets Groups Projects
Commit 695ad671 authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Maybe fix notices going out in the wrong order

parent d46dbf58
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,7 @@ class User(BaseUser): ...@@ -48,6 +48,7 @@ class User(BaseUser):
notice_room: RoomID notice_room: RoomID
_notice_room_lock: asyncio.Lock _notice_room_lock: asyncio.Lock
_notice_send_lock: asyncio.Lock
is_admin: bool is_admin: bool
permission_level: str permission_level: str
_is_logged_in: Optional[bool] _is_logged_in: Optional[bool]
...@@ -69,6 +70,7 @@ class User(BaseUser): ...@@ -69,6 +70,7 @@ class User(BaseUser):
self.mxid = mxid self.mxid = mxid
self.notice_room = notice_room self.notice_room = notice_room
self._notice_room_lock = asyncio.Lock() self._notice_room_lock = asyncio.Lock()
self._notice_send_lock = asyncio.Lock()
self.by_mxid[mxid] = self self.by_mxid[mxid] = self
self.command_status = None self.command_status = None
self.is_whitelisted, self.is_admin, self.permission_level = config.get_permissions(mxid) self.is_whitelisted, self.is_admin, self.permission_level = config.get_permissions(mxid)
...@@ -409,7 +411,9 @@ class User(BaseUser): ...@@ -409,7 +411,9 @@ class User(BaseUser):
else MessageType.NOTICE)) else MessageType.NOTICE))
if edit: if edit:
content.set_edit(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: except Exception:
self.log.warning("Failed to send bridge notice", exc_info=True) self.log.warning("Failed to send bridge notice", exc_info=True)
return edit or event_id return edit or event_id
......
...@@ -4,5 +4,5 @@ alembic>=1,<2 ...@@ -4,5 +4,5 @@ alembic>=1,<2
ruamel.yaml>=0.15.94,<0.17 ruamel.yaml>=0.15.94,<0.17
commonmark>=0.8,<0.10 commonmark>=0.8,<0.10
python-magic>=0.4,<0.5 python-magic>=0.4,<0.5
mautrix==0.5.0 mautrix==0.5.1
fbchat-asyncio==0.6.0b2 fbchat-asyncio==0.6.0b2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment