Add missing receiver_id when syncing direct chat dialogs (ref #425)

This commit is contained in:
Tulir Asokan
2020-05-19 11:30:38 +03:00
parent 74d130644c
commit 8552d463a1
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -402,6 +402,8 @@ class BasePortal(ABC):
@classmethod @classmethod
def get_by_tgid(cls, tgid: TelegramID, tg_receiver: Optional[TelegramID] = None, def get_by_tgid(cls, tgid: TelegramID, tg_receiver: Optional[TelegramID] = None,
peer_type: str = None) -> Optional['Portal']: peer_type: str = None) -> Optional['Portal']:
if peer_type == "user" and tg_receiver is None:
raise ValueError("tg_receiver is required when peer_type is \"user\"")
tg_receiver = tg_receiver or tgid tg_receiver = tg_receiver or tgid
tgid_full = (tgid, tg_receiver) tgid_full = (tgid, tg_receiver)
try: try:
+1 -1
View File
@@ -348,7 +348,7 @@ class User(AbstractUser, BaseUser):
continue continue
elif isinstance(entity, TLUser) and not config["bridge.sync_direct_chats"]: elif isinstance(entity, TLUser) and not config["bridge.sync_direct_chats"]:
continue continue
portal = po.Portal.get_by_entity(entity) portal = po.Portal.get_by_entity(entity, receiver_id=self.tgid)
self.portals[portal.tgid_full] = portal self.portals[portal.tgid_full] = portal
creators.append( creators.append(
portal.create_matrix_room(self, entity, invites=[self.mxid], portal.create_matrix_room(self, entity, invites=[self.mxid],