|
@@ -962,12 +962,21 @@ class Portal(DBPortal, BasePortal):
|
|
async with self._create_room_lock:
|
|
async with self._create_room_lock:
|
|
return await self._create_matrix_room(source, info)
|
|
return await self._create_matrix_room(source, info)
|
|
|
|
|
|
- async def _update_matrix_room(self, source: 'u.User', info: ChatInfo) -> None:
|
|
|
|
|
|
+ def _get_invite_content(self, double_puppet: Optional['p.Puppet']) -> Dict[str, Any]:
|
|
|
|
+ invite_content = {}
|
|
|
|
+ if double_puppet:
|
|
|
|
+ invite_content["fi.mau.will_auto_accept"] = True
|
|
if self.is_direct:
|
|
if self.is_direct:
|
|
- puppet = await p.Puppet.get_by_custom_mxid(source.mxid)
|
|
|
|
- if puppet:
|
|
|
|
- await self.main_intent.invite_user(self.mxid, source.mxid, check_cache=True)
|
|
|
|
- await puppet.intent.ensure_joined(self.mxid)
|
|
|
|
|
|
+ invite_content["is_direct"] = True
|
|
|
|
+ return invite_content
|
|
|
|
+
|
|
|
|
+ async def _update_matrix_room(self, source: 'u.User', info: ChatInfo) -> None:
|
|
|
|
+ puppet = await p.Puppet.get_by_custom_mxid(source.mxid)
|
|
|
|
+ await self.main_intent.invite_user(self.mxid, source.mxid, check_cache=True,
|
|
|
|
+ extra_content=self._get_invite_content(puppet))
|
|
|
|
+ if puppet:
|
|
|
|
+ did_join = await puppet.intent.ensure_joined(self.mxid)
|
|
|
|
+ if did_join and self.is_direct:
|
|
await source.update_direct_chats({self.main_intent.mxid: [self.mxid]})
|
|
await source.update_direct_chats({self.main_intent.mxid: [self.mxid]})
|
|
|
|
|
|
await self.update_info(source, info)
|
|
await self.update_info(source, info)
|
|
@@ -1030,7 +1039,7 @@ class Portal(DBPortal, BasePortal):
|
|
"type": str(EventType.ROOM_POWER_LEVELS),
|
|
"type": str(EventType.ROOM_POWER_LEVELS),
|
|
"content": power_levels.serialize(),
|
|
"content": power_levels.serialize(),
|
|
}]
|
|
}]
|
|
- invites = [source.mxid]
|
|
|
|
|
|
+ invites = []
|
|
if self.config["bridge.encryption.default"] and self.matrix.e2ee:
|
|
if self.config["bridge.encryption.default"] and self.matrix.e2ee:
|
|
self.encrypted = True
|
|
self.encrypted = True
|
|
initial_state.append({
|
|
initial_state.append({
|
|
@@ -1069,20 +1078,22 @@ class Portal(DBPortal, BasePortal):
|
|
self.log.warning("Failed to add bridge bot "
|
|
self.log.warning("Failed to add bridge bot "
|
|
f"to new private chat {self.mxid}")
|
|
f"to new private chat {self.mxid}")
|
|
|
|
|
|
|
|
+ puppet = await p.Puppet.get_by_custom_mxid(source.mxid)
|
|
|
|
+ await self.main_intent.invite_user(self.mxid, source.mxid,
|
|
|
|
+ extra_content=self._get_invite_content(puppet))
|
|
|
|
+ if puppet:
|
|
|
|
+ try:
|
|
|
|
+ await source.update_direct_chats({self.main_intent.mxid: [self.mxid]})
|
|
|
|
+ await puppet.intent.join_room_by_id(self.mxid)
|
|
|
|
+ except MatrixError:
|
|
|
|
+ self.log.debug("Failed to join custom puppet into newly created portal",
|
|
|
|
+ exc_info=True)
|
|
|
|
+
|
|
await self.update()
|
|
await self.update()
|
|
self.log.debug(f"Matrix room created: {self.mxid}")
|
|
self.log.debug(f"Matrix room created: {self.mxid}")
|
|
self.by_mxid[self.mxid] = self
|
|
self.by_mxid[self.mxid] = self
|
|
if not self.is_direct:
|
|
if not self.is_direct:
|
|
await self._update_participants(source, info)
|
|
await self._update_participants(source, info)
|
|
- else:
|
|
|
|
- puppet = await p.Puppet.get_by_custom_mxid(source.mxid)
|
|
|
|
- if puppet:
|
|
|
|
- try:
|
|
|
|
- await puppet.intent.join_room_by_id(self.mxid)
|
|
|
|
- await source.update_direct_chats({self.main_intent.mxid: [self.mxid]})
|
|
|
|
- except MatrixError:
|
|
|
|
- self.log.debug("Failed to join custom puppet into newly created portal",
|
|
|
|
- exc_info=True)
|
|
|
|
|
|
|
|
# TODO
|
|
# TODO
|
|
# in_community = await source._community_helper.add_room(source._community_id, self.mxid)
|
|
# in_community = await source._community_helper.add_room(source._community_id, self.mxid)
|