From dc0ca61e9707c1cec5dd5ab9236570088d77bac5 Mon Sep 17 00:00:00 2001 From: Thomas Renard Date: Sun, 17 Mar 2019 20:11:11 +0100 Subject: [PATCH 1/2] read_markers for room and api implemented --- matrix_client/api.py | 16 ++++++++++++++++ matrix_client/room.py | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/matrix_client/api.py b/matrix_client/api.py index aae52f99..d9d80f1d 100644 --- a/matrix_client/api.py +++ b/matrix_client/api.py @@ -284,6 +284,22 @@ def get_state_event(self, room_id, event_type): """ return self._send("GET", "/rooms/{}/state/{}".format(quote(room_id), event_type)) + def send_read_markers(self, room_id, mfully_read, mread=None): + """Perform PUT /rooms/$room_id/read_markers + + Args: + room_id(str): The room ID. + mfully_read (str): event_id the read marker should located at. + mread (str): (optional) The event ID to set the read receipt location at. + """ + + content = { "m.fully_read": mfully_read } + if mread: + content['m.read'] = mread + + path = "/rooms/{}/read_markers".format( quote(room_id) ) + return self._send("POST", path, content) + def send_message_event(self, room_id, event_type, content, txn_id=None, timestamp=None): """Perform PUT /rooms/$room_id/send/$event_type diff --git a/matrix_client/room.py b/matrix_client/room.py index 9083ed4a..1233afc7 100644 --- a/matrix_client/room.py +++ b/matrix_client/room.py @@ -426,6 +426,19 @@ def send_state_event(self, event_type, content, state_key=""): state_key ) + def send_read_markers(self, mfully_read, mread=None): + """ Send read markers + Args: + room_id(str): The room ID. + mfully_read (str): event_id the read marker should located at. + mread (str): (optional) The event ID to set the read receipt location at. + """ + + return self.client.api.send_read_markers( + self.room_id, + mfully_read, + mread) + def update_room_topic(self): """Updates self.topic and returns True if room topic has changed.""" try: From 8616f02dfe3e922bdcad4f75c93f5824e160ab85 Mon Sep 17 00:00:00 2001 From: Thomas Renard Date: Sun, 17 Mar 2019 21:04:58 +0100 Subject: [PATCH 2/2] pep8 corrections --- matrix_client/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix_client/api.py b/matrix_client/api.py index d9d80f1d..dcf6d213 100644 --- a/matrix_client/api.py +++ b/matrix_client/api.py @@ -293,11 +293,11 @@ def send_read_markers(self, room_id, mfully_read, mread=None): mread (str): (optional) The event ID to set the read receipt location at. """ - content = { "m.fully_read": mfully_read } + content = {"m.fully_read": mfully_read} if mread: content['m.read'] = mread - path = "/rooms/{}/read_markers".format( quote(room_id) ) + path = "/rooms/{}/read_markers".format(quote(room_id)) return self._send("POST", path, content) def send_message_event(self, room_id, event_type, content, txn_id=None,