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
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,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?

* @param {string} roomId ID of the room that has been read
* @param {string} eventId ID of the event that has been read
* @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

* @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?

* @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!

callback = rrEvent;
rrEvent = undefined;
}

const path = utils.encodeUri("/rooms/$roomId/read_marker", {
$roomId: roomId,
});
const content = {
"m.read_marker": eventId,
};

// Add the optional RR update, do local echo like `sendReceipt`
if (rrEvent) {
content["m.read"] = rrEvent.getId();
const room = this.getRoom(roomId);
if (room) {
room._addLocalEchoReceipt(this.credentials.userId, rrEvent, "m.read");
}
}

return this._http.authedRequest(
callback, "POST", path, undefined, content,
);
};

/**
* Set a user's power level.
* @param {string} roomId
Expand Down