You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Implement API for setting RM (#419)
* Implement API for setting RM This is now stored on the server with similar treatment to RRs. The server will only store the specified eventId as the current read marker for a room if the event is ahead in the stream when compared to the existing RM. The exception is when the RM has never been set for this room for this user, in which case the event ID will be stored as the RM without any comparison. This API also allows for an optional RR event ID to be sent in the same request. This is because it might be the common case for some clients to update the RM at the same time as updating the RR. See design: https://docs.google.com/document/d/1UWqdS-e1sdwkLDUY0wA4gZyIkRp-ekjsLZ8k6g_Zvso/edit See server-side PRs: https://github.com/matrix-org/synapse/pull/2120, https://github.com/matrix-org/synapse/pull/2128
This commit is contained in:
@@ -470,6 +470,34 @@ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a marker to indicate the point in a room before which the user has read every
|
||||
* event. This can be retrieved from room account data (the event type is `m.fully_read`)
|
||||
* and displayed as a horizontal line in the timeline that is visually distinct to the
|
||||
* position of the user's own read receipt.
|
||||
* @param {string} roomId ID of the room that has been read
|
||||
* @param {string} rmEventId ID of the event that has been read
|
||||
* @param {string} rrEventId ID of the event tracked by the read receipt. This is here
|
||||
* for convenience because the RR and the RM are commonly updated at the same time as
|
||||
* each other. Optional.
|
||||
* @return {module:client.Promise} Resolves: the empty object, {}.
|
||||
*/
|
||||
MatrixBaseApis.prototype.setRoomReadMarkersHttpRequest =
|
||||
function(roomId, rmEventId, rrEventId) {
|
||||
const path = utils.encodeUri("/rooms/$roomId/read_markers", {
|
||||
$roomId: roomId,
|
||||
});
|
||||
|
||||
const content = {
|
||||
"m.fully_read": rmEventId,
|
||||
"m.read": rrEventId,
|
||||
};
|
||||
|
||||
return this._http.authedRequest(
|
||||
undefined, "POST", path, undefined, content,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Room Directory operations
|
||||
// =========================
|
||||
|
||||
Reference in New Issue
Block a user