m.read_marker -> m.fully_read (#2128)
Also: - change the REST endpoint to have a "S" on the end (so it's now /read_markers) - change the content of the m.read_up_to event to have the key "event_id" instead of "marker".pull/2149/head
parent
c02b6a37d6
commit
3fb8784c92
|
@ -43,7 +43,7 @@ class ReadMarkerHandler(BaseHandler):
|
||||||
with (yield self.read_marker_linearizer.queue((room_id, user_id))):
|
with (yield self.read_marker_linearizer.queue((room_id, user_id))):
|
||||||
account_data = yield self.store.get_account_data_for_room(user_id, room_id)
|
account_data = yield self.store.get_account_data_for_room(user_id, room_id)
|
||||||
|
|
||||||
existing_read_marker = account_data.get("m.read_marker", None)
|
existing_read_marker = account_data.get("m.fully_read", None)
|
||||||
|
|
||||||
should_update = True
|
should_update = True
|
||||||
|
|
||||||
|
@ -51,14 +51,14 @@ class ReadMarkerHandler(BaseHandler):
|
||||||
# Only update if the new marker is ahead in the stream
|
# Only update if the new marker is ahead in the stream
|
||||||
should_update = yield self.store.is_event_after(
|
should_update = yield self.store.is_event_after(
|
||||||
event_id,
|
event_id,
|
||||||
existing_read_marker['marker']
|
existing_read_marker['event_id']
|
||||||
)
|
)
|
||||||
|
|
||||||
if should_update:
|
if should_update:
|
||||||
content = {
|
content = {
|
||||||
"marker": event_id
|
"event_id": event_id
|
||||||
}
|
}
|
||||||
max_id = yield self.store.add_account_data_to_room(
|
max_id = yield self.store.add_account_data_to_room(
|
||||||
user_id, room_id, "m.read_marker", content
|
user_id, room_id, "m.fully_read", content
|
||||||
)
|
)
|
||||||
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
|
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
|
||||||
|
|
|
@ -82,11 +82,11 @@ class RoomAccountDataServlet(RestServlet):
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request)
|
||||||
|
|
||||||
if account_data_type == "m.read_marker":
|
if account_data_type == "m.fully_read":
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
405,
|
405,
|
||||||
"Cannot set m.read_marker through this API."
|
"Cannot set m.fully_read through this API."
|
||||||
" Use /rooms/!roomId:server.name/read_marker"
|
" Use /rooms/!roomId:server.name/read_markers"
|
||||||
)
|
)
|
||||||
|
|
||||||
max_id = yield self.store.add_account_data_to_room(
|
max_id = yield self.store.add_account_data_to_room(
|
||||||
|
|
|
@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ReadMarkerRestServlet(RestServlet):
|
class ReadMarkerRestServlet(RestServlet):
|
||||||
PATTERNS = client_v2_patterns("/rooms/(?P<room_id>[^/]*)/read_marker$")
|
PATTERNS = client_v2_patterns("/rooms/(?P<room_id>[^/]*)/read_markers$")
|
||||||
|
|
||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
super(ReadMarkerRestServlet, self).__init__()
|
super(ReadMarkerRestServlet, self).__init__()
|
||||||
|
@ -51,7 +51,7 @@ class ReadMarkerRestServlet(RestServlet):
|
||||||
event_id=read_event_id
|
event_id=read_event_id
|
||||||
)
|
)
|
||||||
|
|
||||||
read_marker_event_id = body.get("m.read_marker", None)
|
read_marker_event_id = body.get("m.fully_read", None)
|
||||||
if read_marker_event_id:
|
if read_marker_event_id:
|
||||||
yield self.read_marker_handler.received_client_read_marker(
|
yield self.read_marker_handler.received_client_read_marker(
|
||||||
room_id,
|
room_id,
|
||||||
|
|
Loading…
Reference in New Issue