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

Move enable_dm_encryption helper to Portal

parent e4dbc9dd
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,7 @@ class MatrixHandler(BaseMatrixHandler):
portal.mxid = room_id
e2be_ok = None
if self.config["bridge.encryption.default"] and self.e2ee:
e2be_ok = await self.enable_dm_encryption(portal, members=members)
e2be_ok = await portal.enable_dm_encryption()
portal.save()
if e2be_ok is True:
evt_type, content = await self.e2ee.encrypt(
......@@ -122,16 +122,6 @@ class MatrixHandler(BaseMatrixHandler):
message += "\n\nWarning: Failed to enable end-to-bridge encryption"
await intent.send_notice(room_id, message)
async def enable_dm_encryption(self, portal: po.Portal, members: List[UserID]) -> bool:
ok = await super().enable_dm_encryption(portal, members)
if ok:
try:
puppet = pu.Puppet.get_by_fbid(portal.fbid)
await portal.main_intent.set_room_name(portal.mxid, puppet.name)
except Exception:
self.log.warning(f"Failed to set room name for {portal.mxid}", exc_info=True)
return ok
async def handle_invite(self, room_id: RoomID, user_id: UserID, invited_by: 'u.User',
event_id: EventID) -> None:
# TODO handle puppet and user invites for group chats
......
......@@ -662,7 +662,6 @@ class Portal(BasePortal):
if existing and existing.reaction == reaction:
return
# TODO normalize reaction emoji bytes and maybe pre-reject invalid emojis
await fbchat.Message(thread=self.thread_for(sender), id=message.fbid).react(reaction)
await self._upsert_reaction(existing, self.main_intent, event_id, message, sender,
reaction)
......@@ -684,6 +683,16 @@ class Portal(BasePortal):
self._typing = users
await asyncio.gather(*stopped_typing, *started_typing, loop=self.loop)
async def enable_dm_encryption(self) -> bool:
ok = await super().enable_dm_encryption()
if ok:
try:
puppet = p.Puppet.get_by_fbid(self.fbid)
await self.main_intent.set_room_name(self.mxid, puppet.name)
except Exception:
self.log.warning(f"Failed to set room name", exc_info=True)
return ok
# endregion
# region Facebook event handling
......
......@@ -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.6.0.beta6
mautrix==0.6.0.beta7
fbchat-asyncio>=0.6.10,<0.7
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