Skip to content

Commit

Permalink
Completely delete private chat portals when user logs out
Browse files Browse the repository at this point in the history
If it just kicks the user, logging in again later would cause the
bridge to think there's a portal, but fail to invite the user again.

Fixes #397
  • Loading branch information
tulir committed Oct 29, 2020
1 parent 5316ed5 commit fe57386
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mautrix_telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,14 @@ async def log_out(self) -> bool:
for _, portal in self.portals.items():
if not portal or portal.deleted or not portal.mxid or portal.has_bot:
continue
try:
await portal.main_intent.kick_user(portal.mxid, self.mxid,
"Logged out of Telegram.")
except MatrixRequestError:
pass
if portal.peer_type == "user":
await portal.cleanup_portal("Logged out of Telegram")
else:
try:
await portal.main_intent.kick_user(portal.mxid, self.mxid,
"Logged out of Telegram.")
except MatrixRequestError:
pass
self.portals = {}
self.contacts = []
await self.save(portals=True, contacts=True)
Expand Down

0 comments on commit fe57386

Please sign in to comment.