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

Implement API for setting RM #419

Merged
merged 9 commits into from
Apr 20, 2017
Merged

Conversation

lukebarnard1
Copy link
Contributor

@lukebarnard1 lukebarnard1 commented Apr 12, 2017

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: matrix-org/synapse#2120, matrix-org/synapse#2128

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 PR: matrix-org/synapse#2120
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move as much of this as possible into a low-level func in base-apis.js

might make more sense to put it next to sendReadReceipt.

src/client.js Outdated
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.setRoomReadMarker = function(roomId, eventId, rrEvent, callback) {
if (typeof rrEventId === 'function') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a thing? some functions have this sort of hackery, but it's just for backwards compat. You shouldn't need it for a new func

Copy link
Contributor Author

@lukebarnard1 lukebarnard1 Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that callback will be removed, this is no longer required!

src/client.js Outdated
* @param {string} rrEvent 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.
* @param {module:client.callback} callback Optional.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're deprecating callbacks and not adding them for new funcs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. OK

src/client.js Outdated
* convenience because the RR and the RM are commonly updated at the same time as each
* other. Optional.
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you find something better than this please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it to be terrible to do (See @http.authedRequest) or whatever?

src/client.js Outdated
@@ -843,6 +843,43 @@ MatrixClient.prototype.setRoomAccountData = function(roomId, eventType,
};

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does it DOOOOOOOOOO?

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh Apr 13, 2017
Luke Barnard added 2 commits April 18, 2017 09:40
 - Describe setRoomReadMarker
 - remove callback; these are deprecated
 - document "Resolves:"
@lukebarnard1
Copy link
Contributor Author

can you move as much of this as possible into a low-level func in base-apis.js

I'm guessing you mean

const room = this.getRoom(roomId);
if (room) {
    room._addLocalEchoReceipt(this.credentials.userId, rrEvent, "m.read");
}

but getRoom is in client.js so it'd feel wrong to move it.

@lukebarnard1 lukebarnard1 assigned richvdh and unassigned lukebarnard1 Apr 18, 2017
@richvdh
Copy link
Member

richvdh commented Apr 18, 2017 via email

Because typeof null is object
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you base this on develop, not master, please

release.sh Outdated
@@ -237,6 +237,7 @@ fi

# if it is a pre-release, leave it on the release branch for now.
if [ $prerelease -eq 1 ]; then
git checkout "$rel_branch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

src/base-apis.js Outdated
* for convenience because the RR and the RM are commonly updated at the same time as
* each other. Optional.
* @return {module:client.Promise} Resolves: (@see module:http-api.authedRequest)
* @return {module:http-api.MatrixError} Rejects: with an error response.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it never returns a MatrixError; it always returns a Promise.

Sorry, I should have been clearer about what to put here. There are a lot of historical functions (including authedRequest) which are basically full of shit. Note also that httpApi.opts.onlyData is true as far as base-apis is concerned, so authedRequest always just returns the result of the api call, so linking to that isn't particularly helpful.

Basically the best thing to do here is just have one @return line, along the lines of:

@return {module:client.Promise} resolves to the result object for the API call.

If you have the time and energy to document the shame of that object, so much the better, but generally we expect people to go and read the spec.

src/base-apis.js Outdated
@@ -470,6 +470,33 @@ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {
);
};

/**
* Set a marker to represent which event the user was last reading in a room. This can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not the event the user was last reading though, is it?

src/client.js Outdated
* @return {module:client.Promise} Resolves: (@see module:http-api.authedRequest)
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.setRoomReadMarker = function(roomId, eventId, rrEvent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not distinguish these two by the presence or absence of 's'.

How about calling the other setRoomReadMarkersHttpRequest or something (we have a _sendEventHttpRequest for distinction from _sendEvent)

@@ -1201,6 +1201,33 @@ MatrixClient.prototype.sendReadReceipt = function(event, callback) {
return this.sendReceipt(event, "m.read", callback);
};

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdocs need tweaks as above

@@ -318,6 +318,13 @@ InteractiveAuth.prototype = {
}
this._currentStage = nextStage;

if (nextStage == 'm.login.dummy') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@lukebarnard1 lukebarnard1 changed the base branch from master to develop April 18, 2017 16:33
@richvdh richvdh assigned lukebarnard1 and unassigned richvdh Apr 18, 2017
@lukebarnard1
Copy link
Contributor Author

Now that I've changed the base of the merge, those changes to release.sh and interactive-auth.js should've disappeared

@lukebarnard1 lukebarnard1 assigned richvdh and unassigned lukebarnard1 Apr 19, 2017
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh Apr 19, 2017
@lukebarnard1 lukebarnard1 merged commit 4c63906 into develop Apr 20, 2017
@t3chguy t3chguy deleted the luke/feature-read-marker-api branch May 10, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants