You've already forked matrix-js-sdk
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:
@@ -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.
|
* @param {module:client.callback} callback Optional.
|
||||||
* @return {module:client.Promise} Resolves: TODO
|
* @return {module:client.Promise} Resolves: TODO
|
||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
* @throws If 'presence' isn't a valid presence enum value.
|
* @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", {
|
var path = utils.encodeUri("/presence/$userId/status", {
|
||||||
$userId: this.credentials.userId
|
$userId: this.credentials.userId
|
||||||
});
|
});
|
||||||
var validStates = ["offline", "online", "unavailable"];
|
|
||||||
if (validStates.indexOf(presence) == -1) {
|
var content;
|
||||||
throw new Error("Bad presence value: " + presence);
|
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(
|
return this._http.authedRequest(
|
||||||
callback, "PUT", path, undefined, content
|
callback, "PUT", path, undefined, content
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user