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
Merge pull request #167 from Half-Shot/presence_status
Added ability to set and get status_msg for presence.
This commit is contained in:
@@ -1413,25 +1413,29 @@ 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);
|
||||
|
||||
if (typeof opts === "string") {
|
||||
opts = { presence: opts }
|
||||
}
|
||||
|
||||
var validStates = ["offline", "online", "unavailable"];
|
||||
if (validStates.indexOf(opts.presence) == -1) {
|
||||
throw new Error("Bad presence value: " + opts.presence);
|
||||
}
|
||||
var content = {
|
||||
presence: presence
|
||||
};
|
||||
return this._http.authedRequest(
|
||||
callback, "PUT", path, undefined, content
|
||||
callback, "PUT", path, undefined, opts
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user