Skip to content

Commit

Permalink
Actually ignore ChatForbidden when syncing. Fixes #446
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed May 20, 2020
1 parent f454803 commit c126e8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mautrix_telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from mautrix.errors import MatrixRequestError
from mautrix.types import UserID
from mautrix.bridge import BaseUser
from mautrix.util.logging import TraceLogger

from .types import TelegramID
from .db import User as DBUser
Expand All @@ -45,7 +46,7 @@


class User(AbstractUser, BaseUser):
log: logging.Logger = logging.getLogger("mau.user")
log: TraceLogger = logging.getLogger("mau.user")
by_mxid: Dict[str, 'User'] = {}
by_tgid: Dict[int, 'User'] = {}

Expand Down Expand Up @@ -343,10 +344,12 @@ async def sync_dialogs(self, synchronous_create: bool = False) -> None:
entity = dialog.entity
if isinstance(entity, ChatForbidden):
self.log.warning(f"Ignoring forbidden chat {entity} while syncing")
continue
elif isinstance(entity, Chat) and (entity.deactivated or entity.left):
self.log.warning(f"Ignoring deactivated or left chat {entity} while syncing")
continue
elif isinstance(entity, TLUser) and not config["bridge.sync_direct_chats"]:
self.log.trace(f"Ignoring user {entity.id} while syncing")
continue
portal = po.Portal.get_by_entity(entity, receiver_id=self.tgid)
self.portals[portal.tgid_full] = portal
Expand Down

0 comments on commit c126e8b

Please sign in to comment.