Skip to content

Commit

Permalink
Graceful handling of missing or empty event.unsigned object.
Browse files Browse the repository at this point in the history
  • Loading branch information
jevolk authored and tulir committed Feb 4, 2021
1 parent bc63b0e commit 7171e9c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mautrix/bridge/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from mautrix.types import (EventID, RoomID, UserID, Event, EventType, MessageEvent, MessageType,
MessageEventContent, StateEvent, Membership, MemberStateEventContent,
PresenceEvent, TypingEvent, ReceiptEvent, TextMessageEventContent,
EncryptedEvent, ReceiptType, SingleReceiptEventContent)
EncryptedEvent, ReceiptType, SingleReceiptEventContent, StateUnsigned)
from mautrix.errors import IntentError, MatrixError, MForbidden, DecryptionError, SessionNotFound
from mautrix.appservice import AppService
from mautrix.util.logging import TraceLogger
Expand Down Expand Up @@ -405,7 +405,8 @@ async def int_handle_event(self, evt: Event) -> None:

if evt.type == EventType.ROOM_MEMBER:
evt: StateEvent
prev_content = evt.unsigned.prev_content or MemberStateEventContent()
unsigned = evt.unsigned or StateUnsigned()
prev_content = unsigned.prev_content or MemberStateEventContent()
prev_membership = prev_content.membership if prev_content else Membership.JOIN
if evt.content.membership == Membership.INVITE:
await self.int_handle_invite(evt.room_id, UserID(evt.state_key), evt.sender,
Expand Down

0 comments on commit 7171e9c

Please sign in to comment.