Add join event class.
This commit is contained in:
parent
2a0cccc191
commit
9577472ad2
3 changed files with 44 additions and 0 deletions
|
@ -435,6 +435,15 @@ class MatrixJoinMessage(MatrixMessage):
|
|||
data
|
||||
)
|
||||
|
||||
def decode_body(self, server):
|
||||
object_hook = partial(
|
||||
MatrixEvents.MatrixJoinEvent.from_dict,
|
||||
server,
|
||||
self.room_id
|
||||
)
|
||||
|
||||
return self._decode(server, object_hook)
|
||||
|
||||
|
||||
class MatrixPartMessage(MatrixMessage):
|
||||
def __init__(self, client, room_id):
|
||||
|
|
|
@ -206,3 +206,26 @@ class MatrixRedactEvent(MatrixEvent):
|
|||
False,
|
||||
parsed_dict
|
||||
)
|
||||
|
||||
|
||||
class MatrixJoinEvent(MatrixEvent):
|
||||
def __init__(self, server, room_id, event_id):
|
||||
self.room_id = room_id
|
||||
self.event_id = event_id
|
||||
MatrixEvent.__init__(self, server)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, server, room_id, parsed_dict):
|
||||
try:
|
||||
return cls(
|
||||
server,
|
||||
room_id,
|
||||
sanitize_id(parsed_dict["event_id"]),
|
||||
)
|
||||
except KeyError:
|
||||
return MatrixErrorEvent.from_dict(
|
||||
server,
|
||||
"Error joining room",
|
||||
False,
|
||||
parsed_dict
|
||||
)
|
||||
|
|
|
@ -782,6 +782,18 @@ def handle_http_response(server, message):
|
|||
error=message.response.body)
|
||||
server_buffer_prnt(server, error_message)
|
||||
|
||||
elif status_code == 404:
|
||||
if message.type == MessageType.JOIN:
|
||||
event = message.event
|
||||
event.execute()
|
||||
|
||||
else:
|
||||
error_message = ("{prefix}Unhandled 404 error, please inform the "
|
||||
"developers about this: {error}").format(
|
||||
prefix=W.prefix("error"),
|
||||
error=message.response.body)
|
||||
server_buffer_prnt(server, error_message)
|
||||
|
||||
else:
|
||||
server_buffer_prnt(
|
||||
server,
|
||||
|
|
Loading…
Reference in a new issue