1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Add status_msg to setPresence

This commit is contained in:
Will Hunt
2016-08-09 17:23:30 +01:00
parent 34919d1b96
commit bc56213010

View File

@@ -1417,23 +1417,28 @@ MatrixClient.prototype.mxcUrlToHttp =
};
/**
* @param {string} presence
* @param {Object} opts Options to apply
* @param {string} opts.presence One of "online", "offline" or "unavailable"
* @param {string} opts.status_msg The status message to attach.
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
* @throws If 'presence' isn't a valid presence enum value.
*/
MatrixClient.prototype.setPresence = function(presence, callback) {
MatrixClient.prototype.setPresence = function(opts, callback) {
var path = utils.encodeUri("/presence/$userId/status", {
$userId: this.credentials.userId
});
var validStates = ["offline", "online", "unavailable"];
if (validStates.indexOf(presence) == -1) {
throw new Error("Bad presence value: " + presence);
var content;
if (typeof opts === "string") {
content = { presence: opts }
}
var validStates = ["offline", "online", "unavailable"];
if (validStates.indexOf(content.presence) == -1) {
throw new Error("Bad presence value: " + content.presence);
}
var content = {
presence: presence
};
return this._http.authedRequest(
callback, "PUT", path, undefined, content
);