Split out state messages, for now only topic messages are implemented.
This commit is contained in:
parent
ce718a9259
commit
90c63c197c
3 changed files with 7 additions and 7 deletions
|
@ -38,7 +38,7 @@ class MessageType(Enum):
|
||||||
LOGIN = 0
|
LOGIN = 0
|
||||||
SYNC = 1
|
SYNC = 1
|
||||||
SEND = 2
|
SEND = 2
|
||||||
STATE = 3
|
TOPIC = 3
|
||||||
REDACT = 4
|
REDACT = 4
|
||||||
ROOM_MSG = 5
|
ROOM_MSG = 5
|
||||||
JOIN = 6
|
JOIN = 6
|
||||||
|
@ -247,7 +247,7 @@ class MatrixMessage:
|
||||||
elif message_type == MessageType.SEND:
|
elif message_type == MessageType.SEND:
|
||||||
self.request = server.client.room_send_message(room_id, data)
|
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":
|
if extra_id == "m.room.topic":
|
||||||
self.request = server.client.room_topic(room_id, data)
|
self.request = server.client.room_topic(room_id, data)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -910,7 +910,7 @@ def matrix_command_topic_cb(data, buffer, command):
|
||||||
message = MatrixMessage(
|
message = MatrixMessage(
|
||||||
server,
|
server,
|
||||||
OPTIONS,
|
OPTIONS,
|
||||||
MessageType.STATE,
|
MessageType.TOPIC,
|
||||||
data=topic,
|
data=topic,
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
extra_id="m.room.topic"
|
extra_id="m.room.topic"
|
||||||
|
|
|
@ -743,8 +743,8 @@ def matrix_handle_message(
|
||||||
|
|
||||||
room.prev_batch = response['end']
|
room.prev_batch = response['end']
|
||||||
|
|
||||||
# Nothing to do here, we'll handle state changes and redactions in the sync
|
# Nothing to do here, we'll handle topic changes and redactions in the sync
|
||||||
elif (message_type == MessageType.STATE or
|
elif (message_type == MessageType.TOPIC or
|
||||||
message_type == MessageType.REDACT):
|
message_type == MessageType.REDACT):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -810,12 +810,12 @@ def handle_http_response(server, message):
|
||||||
server.timer_hook = None
|
server.timer_hook = None
|
||||||
|
|
||||||
server.disconnect()
|
server.disconnect()
|
||||||
elif message.type == MessageType.STATE:
|
elif message.type == MessageType.TOPIC:
|
||||||
response = decode_json(server, message.response.body)
|
response = decode_json(server, message.response.body)
|
||||||
reason = ("." if not response or not response["error"] else
|
reason = ("." if not response or not response["error"] else
|
||||||
": {r}.".format(r=response["error"]))
|
": {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"),
|
prefix=W.prefix("network"),
|
||||||
reason=reason)
|
reason=reason)
|
||||||
server_buffer_prnt(server, error_message)
|
server_buffer_prnt(server, error_message)
|
||||||
|
|
Loading…
Add table
Reference in a new issue