Move enable_dm_encryption helper to Portal
This commit is contained in:
@@ -115,7 +115,7 @@ class MatrixHandler(BaseMatrixHandler):
|
|||||||
portal.mxid = room_id
|
portal.mxid = room_id
|
||||||
e2be_ok = None
|
e2be_ok = None
|
||||||
if self.config["bridge.encryption.default"] and self.e2ee:
|
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()
|
portal.save()
|
||||||
inviter.register_portal(portal)
|
inviter.register_portal(portal)
|
||||||
if e2be_ok is True:
|
if e2be_ok is True:
|
||||||
@@ -135,16 +135,6 @@ class MatrixHandler(BaseMatrixHandler):
|
|||||||
await intent.send_notice(room_id, "This puppet will remain inactive until a "
|
await intent.send_notice(room_id, "This puppet will remain inactive until a "
|
||||||
"Telegram chat is created for this room.")
|
"Telegram chat is created for this room.")
|
||||||
|
|
||||||
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(portal.tgid)
|
|
||||||
await portal.main_intent.set_room_name(portal.mxid, puppet.displayname)
|
|
||||||
except Exception:
|
|
||||||
self.log.warning(f"Failed to set room name for {portal.mxid}", exc_info=True)
|
|
||||||
return ok
|
|
||||||
|
|
||||||
async def send_welcome_message(self, room_id: RoomID, inviter: 'u.User') -> None:
|
async def send_welcome_message(self, room_id: RoomID, inviter: 'u.User') -> None:
|
||||||
try:
|
try:
|
||||||
is_management = len(await self.az.intent.get_room_members(room_id)) == 2
|
is_management = len(await self.az.intent.get_room_members(room_id)) == 2
|
||||||
|
|||||||
@@ -574,6 +574,15 @@ class PortalMatrix(BasePortal, MautrixBasePortal, ABC):
|
|||||||
self.db_instance.edit(mxid=self.mxid)
|
self.db_instance.edit(mxid=self.mxid)
|
||||||
self.by_mxid[self.mxid] = self
|
self.by_mxid[self.mxid] = self
|
||||||
|
|
||||||
|
async def enable_dm_encryption(self) -> bool:
|
||||||
|
ok = await super().enable_dm_encryption()
|
||||||
|
if ok:
|
||||||
|
try:
|
||||||
|
puppet = p.Puppet.get(self.tgid)
|
||||||
|
await self.main_intent.set_room_name(self.mxid, puppet.displayname)
|
||||||
|
except Exception:
|
||||||
|
self.log.warning(f"Failed to set room name", exc_info=True)
|
||||||
|
return ok
|
||||||
|
|
||||||
def init(context: Context) -> None:
|
def init(context: Context) -> None:
|
||||||
global config
|
global config
|
||||||
|
|||||||
+1
-1
@@ -4,6 +4,6 @@ ruamel.yaml>=0.15.35,<0.17
|
|||||||
python-magic>=0.4,<0.5
|
python-magic>=0.4,<0.5
|
||||||
commonmark>=0.8,<0.10
|
commonmark>=0.8,<0.10
|
||||||
aiohttp>=3,<4
|
aiohttp>=3,<4
|
||||||
mautrix==0.6.0.beta6
|
mautrix==0.6.0.beta7
|
||||||
telethon>=1.13,<1.16
|
telethon>=1.13,<1.16
|
||||||
telethon-session-sqlalchemy>=0.2.14,<0.3
|
telethon-session-sqlalchemy>=0.2.14,<0.3
|
||||||
|
|||||||
Reference in New Issue
Block a user