forked from fair/matrix-puppeteer-line
Don't error on member leave if puppet left already
This commit is contained in:
parent
9e739e9908
commit
e0f21ed824
|
@ -30,6 +30,7 @@ from mautrix.types import (EventID, MessageEventContent, RoomID, EventType, Mess
|
||||||
ContentURI, EncryptedFile, ImageInfo,
|
ContentURI, EncryptedFile, ImageInfo,
|
||||||
RelatesTo, RelationType)
|
RelatesTo, RelationType)
|
||||||
from mautrix.errors import IntentError
|
from mautrix.errors import IntentError
|
||||||
|
from mautrix.errors.request import MatrixRequestError
|
||||||
from mautrix.util.simple_lock import SimpleLock
|
from mautrix.util.simple_lock import SimpleLock
|
||||||
|
|
||||||
from .db import Portal as DBPortal, Message as DBMessage, Receipt as DBReceipt, ReceiptReaction as DBReceiptReaction, Media as DBMedia
|
from .db import Portal as DBPortal, Message as DBMessage, Receipt as DBReceipt, ReceiptReaction as DBReceiptReaction, Media as DBMedia
|
||||||
|
@ -370,7 +371,10 @@ class Portal(DBPortal, BasePortal):
|
||||||
if evt.member_info.joined:
|
if evt.member_info.joined:
|
||||||
await intent.ensure_joined(self.mxid)
|
await intent.ensure_joined(self.mxid)
|
||||||
elif evt.member_info.left:
|
elif evt.member_info.left:
|
||||||
await intent.leave_room(self.mxid)
|
try:
|
||||||
|
await intent.leave_room(self.mxid)
|
||||||
|
except MatrixRequestError as e:
|
||||||
|
self.log.warn(f"Puppet for user {evt.sender.id} already left portal {self.mxid}")
|
||||||
event_id = None
|
event_id = None
|
||||||
else:
|
else:
|
||||||
content = TextMessageEventContent(
|
content = TextMessageEventContent(
|
||||||
|
|
Loading…
Reference in New Issue