rooms: Add BadEvent class.
This way if one event in a room is not per spec, we don't end up in a broken state.
This commit is contained in:
parent
d70e651d3e
commit
810607dc08
1 changed files with 18 additions and 1 deletions
|
@ -287,7 +287,8 @@ class RoomInfo():
|
||||||
error=pformat(error),
|
error=pformat(error),
|
||||||
event=pformat(event))
|
event=pformat(event))
|
||||||
W.prnt("", message)
|
W.prnt("", message)
|
||||||
raise
|
e = BadEvent.from_dict(event)
|
||||||
|
events.append(e)
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -325,6 +326,22 @@ class RoomEvent():
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
|
|
||||||
|
|
||||||
|
class BadEvent(RoomEvent):
|
||||||
|
def __init__(self, event_id, sender, timestamp, source):
|
||||||
|
self.source = source
|
||||||
|
|
||||||
|
def from_dict(cls, event):
|
||||||
|
event_id = (sanitize_id(event["event_id"])
|
||||||
|
if "event_id" in event else None)
|
||||||
|
sender = (sanitize_id(event["sender"])
|
||||||
|
if "sender" in event else None)
|
||||||
|
timestamp = (sanitize_id(event["origin_server_ts"])
|
||||||
|
if "origin_server_ts" in event else None)
|
||||||
|
source = json.dumps(event)
|
||||||
|
|
||||||
|
return cls(event_id, sender, timestamp, source)
|
||||||
|
|
||||||
|
|
||||||
class RoomRedactedMessageEvent(RoomEvent):
|
class RoomRedactedMessageEvent(RoomEvent):
|
||||||
|
|
||||||
def __init__(self, event_id, sender, timestamp, censor, reason=None):
|
def __init__(self, event_id, sender, timestamp, censor, reason=None):
|
||||||
|
|
Loading…
Reference in a new issue