Add redaction event class.
This commit is contained in:
parent
3232f61f7e
commit
2a0cccc191
3 changed files with 42 additions and 2 deletions
|
@ -375,6 +375,7 @@ class MatrixRedactMessage(MatrixMessage):
|
||||||
def __init__(self, client, room_id, event_id, reason=None):
|
def __init__(self, client, room_id, event_id, reason=None):
|
||||||
self.room_id = room_id
|
self.room_id = room_id
|
||||||
self.event_id = event_id
|
self.event_id = event_id
|
||||||
|
self.reason = reason
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -391,6 +392,16 @@ class MatrixRedactMessage(MatrixMessage):
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def decode_body(self, server):
|
||||||
|
object_hook = partial(
|
||||||
|
MatrixEvents.MatrixRedactEvent.from_dict,
|
||||||
|
server,
|
||||||
|
self.room_id,
|
||||||
|
self.reason,
|
||||||
|
)
|
||||||
|
|
||||||
|
return self._decode(server, object_hook)
|
||||||
|
|
||||||
|
|
||||||
class MatrixBacklogMessage(MatrixMessage):
|
class MatrixBacklogMessage(MatrixMessage):
|
||||||
def __init__(self, client, room_id, token, limit):
|
def __init__(self, client, room_id, token, limit):
|
||||||
|
|
|
@ -181,3 +181,28 @@ class MatrixTopicEvent(MatrixEvent):
|
||||||
False,
|
False,
|
||||||
parsed_dict
|
parsed_dict
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixRedactEvent(MatrixEvent):
|
||||||
|
def __init__(self, server, room_id, event_id, reason):
|
||||||
|
self.room_id = room_id
|
||||||
|
self.topic = reason
|
||||||
|
self.event_id = event_id
|
||||||
|
MatrixEvent.__init__(self, server)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, server, room_id, reason, parsed_dict):
|
||||||
|
try:
|
||||||
|
return cls(
|
||||||
|
server,
|
||||||
|
room_id,
|
||||||
|
sanitize_id(parsed_dict["event_id"]),
|
||||||
|
reason
|
||||||
|
)
|
||||||
|
except KeyError:
|
||||||
|
return MatrixErrorEvent.from_dict(
|
||||||
|
server,
|
||||||
|
"Error redacting message",
|
||||||
|
False,
|
||||||
|
parsed_dict
|
||||||
|
)
|
||||||
|
|
|
@ -720,9 +720,9 @@ def matrix_handle_message(
|
||||||
|
|
||||||
room.prev_batch = response['end']
|
room.prev_batch = response['end']
|
||||||
|
|
||||||
# Nothing to do here, we'll handle topic changes and redactions in the sync
|
|
||||||
elif message_type == MessageType.REDACT:
|
elif message_type == MessageType.REDACT:
|
||||||
pass
|
event = message.event
|
||||||
|
event.execute()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
server_buffer_prnt(
|
server_buffer_prnt(
|
||||||
|
@ -771,6 +771,10 @@ def handle_http_response(server, message):
|
||||||
event = message.event
|
event = message.event
|
||||||
event.execute()
|
event.execute()
|
||||||
|
|
||||||
|
elif message.type == MessageType.REDACT:
|
||||||
|
event = message.event
|
||||||
|
event.execute()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
error_message = ("{prefix}Unhandled 403 error, please inform the "
|
error_message = ("{prefix}Unhandled 403 error, please inform the "
|
||||||
"developers about this: {error}").format(
|
"developers about this: {error}").format(
|
||||||
|
|
Loading…
Reference in a new issue