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
Ensure we have power to set custom status
If we're in a non-DM room of 2 people, we may not have power to set state events like custom status. Ensure that we do before sending.
This commit is contained in:
@@ -2280,16 +2280,21 @@ MatrixClient.prototype.mxcUrlToHttp =
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype._unstable_setStatusMessage = function(newMessage) {
|
||||
const type = "im.vector.user_status";
|
||||
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 {
|
||||
if (!isJoined || !looksLikeDm) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
// Check power level separately as it's a bit more expensive.
|
||||
const maySend = room.currentState.mayClientSendStateEvent(type, this);
|
||||
if (!maySend) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this.sendStateEvent(room.roomId, type, {
|
||||
status: newMessage,
|
||||
}, this.getUserId());
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user