mirror of https://github.com/vector-im/riot-web
Add encryption option to createRoom
parent
c25c1878b8
commit
2b16b650fe
|
@ -34,6 +34,8 @@ import {getAddressType} from "./UserAddress";
|
||||||
* Default: True
|
* Default: True
|
||||||
* @param {bool=} opts.guestAccess Whether to enable guest access.
|
* @param {bool=} opts.guestAccess Whether to enable guest access.
|
||||||
* Default: True
|
* Default: True
|
||||||
|
* @param {bool=} opts.encryption Whether to enable encryption.
|
||||||
|
* Default: False
|
||||||
*
|
*
|
||||||
* @returns {Promise} which resolves to the room id, or null if the
|
* @returns {Promise} which resolves to the room id, or null if the
|
||||||
* action was aborted or failed.
|
* action was aborted or failed.
|
||||||
|
@ -42,6 +44,7 @@ export default function createRoom(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
if (opts.spinner === undefined) opts.spinner = true;
|
if (opts.spinner === undefined) opts.spinner = true;
|
||||||
if (opts.guestAccess === undefined) opts.guestAccess = true;
|
if (opts.guestAccess === undefined) opts.guestAccess = true;
|
||||||
|
if (opts.encryption === undefined) opts.encryption = false;
|
||||||
|
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
@ -80,17 +83,28 @@ export default function createRoom(opts) {
|
||||||
opts.andView = true;
|
opts.andView = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createOpts.initial_state = createOpts.initial_state || [];
|
||||||
|
|
||||||
// Allow guests by default since the room is private and they'd
|
// Allow guests by default since the room is private and they'd
|
||||||
// need an invite. This means clicking on a 3pid invite email can
|
// need an invite. This means clicking on a 3pid invite email can
|
||||||
// actually drop you right in to a chat.
|
// actually drop you right in to a chat.
|
||||||
createOpts.initial_state = createOpts.initial_state || [];
|
|
||||||
if (opts.guestAccess) {
|
if (opts.guestAccess) {
|
||||||
createOpts.initial_state.push({
|
createOpts.initial_state.push({
|
||||||
|
type: 'm.room.guest_access',
|
||||||
|
state_key: '',
|
||||||
content: {
|
content: {
|
||||||
guest_access: 'can_join',
|
guest_access: 'can_join',
|
||||||
},
|
},
|
||||||
type: 'm.room.guest_access',
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.encryption) {
|
||||||
|
createOpts.initial_state.push({
|
||||||
|
type: 'm.room.encryption',
|
||||||
state_key: '',
|
state_key: '',
|
||||||
|
content: {
|
||||||
|
algorithm: 'm.megolm.v1.aes-sha2',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue