-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Conversation
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
There was a problem hiding this 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') { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're deprecating callback
s and not adding them for new funcs
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, | |||
}; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it DOOOOOOOOOO?
- Describe setRoomReadMarker - remove callback; these are deprecated - document "Resolves:"
I'm guessing you mean const room = this.getRoom(roomId);
if (room) {
room._addLocalEchoReceipt(this.credentials.userId, rrEvent, "m.read");
} but |
No, I mean the all the rest of it.
…On 18/04/17 09:46, Luke Barnard wrote:
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.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#419 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABU1VImGWRCRAlBQz7baG6dSqTp6wos-ks5rxHh8gaJpZM4M7qgI>.
|
Because typeof null is object
There was a problem hiding this 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" |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); | |||
}; | |||
|
|||
/** |
There was a problem hiding this comment.
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
src/interactive-auth.js
Outdated
@@ -318,6 +318,13 @@ InteractiveAuth.prototype = { | |||
} | |||
this._currentStage = nextStage; | |||
|
|||
if (nextStage == 'm.login.dummy') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Now that I've changed the base of the merge, those changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
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