Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read markers #301

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions matrix_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions matrix_client/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down