You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Add setGuestAccess to allow easy room guest access configuration.
This commit is contained in:
@@ -1946,6 +1946,34 @@ MatrixClient.prototype.setGuestRooms = function(roomIds) {
|
||||
this._guestRooms = roomIds;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set r/w flags for guest access in a room.
|
||||
* @param {string} roomId The room to configure guest access in.
|
||||
* @param {Object} opts Options
|
||||
* @param {boolean} opts.allowJoin True to allow guests to join this room. This
|
||||
* implicitly gives guests write access. If false or not given, guests are
|
||||
* explicitly forbidden from joining the room.
|
||||
* @param {boolean} opts.allowRead True to set history visibility to
|
||||
* be world_readable. This gives guests read access *from this point forward*.
|
||||
* If false or not given, history visibility is not modified.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.setGuestAccess = function(roomId, opts) {
|
||||
var writePromise = this.sendStateEvent(roomId, "m.room.guest_access", {
|
||||
guest_access: opts.allowJoin ? "can_join" : "forbidden"
|
||||
});
|
||||
|
||||
var readPromise = q();
|
||||
if (opts.allowRead) {
|
||||
readPromise = this.sendStateEvent(roomId, "m.room.history_visibility", {
|
||||
history_visibility: "world_readable"
|
||||
});
|
||||
}
|
||||
|
||||
return q.all(readPromise, writePromise);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} username
|
||||
* @param {string} password
|
||||
|
Reference in New Issue
Block a user