From 90c63c197cd950ffeee18c3b82f527fc1282a14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Wed, 7 Feb 2018 12:42:56 +0100 Subject: [PATCH] Split out state messages, for now only topic messages are implemented. --- matrix/api.py | 4 ++-- matrix/commands.py | 2 +- matrix/messages.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/matrix/api.py b/matrix/api.py index 786ab38..904853a 100644 --- a/matrix/api.py +++ b/matrix/api.py @@ -38,7 +38,7 @@ class MessageType(Enum): LOGIN = 0 SYNC = 1 SEND = 2 - STATE = 3 + TOPIC = 3 REDACT = 4 ROOM_MSG = 5 JOIN = 6 @@ -247,7 +247,7 @@ class MatrixMessage: elif message_type == MessageType.SEND: self.request = server.client.room_send_message(room_id, data) - elif message_type == MessageType.STATE: + elif message_type == MessageType.TOPIC: if extra_id == "m.room.topic": self.request = server.client.room_topic(room_id, data) else: diff --git a/matrix/commands.py b/matrix/commands.py index 9bf6bfb..25d7a7d 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -910,7 +910,7 @@ def matrix_command_topic_cb(data, buffer, command): message = MatrixMessage( server, OPTIONS, - MessageType.STATE, + MessageType.TOPIC, data=topic, room_id=room_id, extra_id="m.room.topic" diff --git a/matrix/messages.py b/matrix/messages.py index 37e73bb..6ff6b51 100644 --- a/matrix/messages.py +++ b/matrix/messages.py @@ -743,8 +743,8 @@ def matrix_handle_message( room.prev_batch = response['end'] - # Nothing to do here, we'll handle state changes and redactions in the sync - elif (message_type == MessageType.STATE or + # Nothing to do here, we'll handle topic changes and redactions in the sync + elif (message_type == MessageType.TOPIC or message_type == MessageType.REDACT): pass @@ -810,12 +810,12 @@ def handle_http_response(server, message): server.timer_hook = None server.disconnect() - elif message.type == MessageType.STATE: + elif message.type == MessageType.TOPIC: response = decode_json(server, message.response.body) reason = ("." if not response or not response["error"] else ": {r}.".format(r=response["error"])) - error_message = ("{prefix}Can't set state{reason}").format( + error_message = ("{prefix}Can't set topic{reason}").format( prefix=W.prefix("network"), reason=reason) server_buffer_prnt(server, error_message)