You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Support setting status message in rooms that look like 1:1s
Part of https://github.com/vector-im/riot-web/issues/1528
This commit is contained in:
@@ -2262,6 +2262,27 @@ MatrixClient.prototype.mxcUrlToHttp =
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new status message for the user. The message may be null/falsey
|
||||||
|
* to clear the message.
|
||||||
|
* @param {string} newMessage The new message to set.
|
||||||
|
* @return {module:client.Promise} Resolves: to nothing
|
||||||
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.setStatusMessage = function(newMessage) {
|
||||||
|
return Promise.all(this.getRooms().map((room) => {
|
||||||
|
const isJoined = room.getMyMembership() === "join";
|
||||||
|
const looksLikeDm = room.getInvitedAndJoinedMemberCount() === 2;
|
||||||
|
if (isJoined && looksLikeDm) {
|
||||||
|
return this.sendStateEvent(room.roomId, "im.vector.user_status", {
|
||||||
|
status: newMessage,
|
||||||
|
}, this.getUserId());
|
||||||
|
} else {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} opts Options to apply
|
* @param {Object} opts Options to apply
|
||||||
* @param {string} opts.presence One of "online", "offline" or "unavailable"
|
* @param {string} opts.presence One of "online", "offline" or "unavailable"
|
||||||
|
|||||||
Reference in New Issue
Block a user