Skip to content

Commit

Permalink
Lint createTchapRoom.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
estellecomment committed Aug 29, 2022
1 parent fd52c21 commit 2519605
Showing 1 changed file with 39 additions and 40 deletions.
79 changes: 39 additions & 40 deletions src/lib/createTchapRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,52 @@ export const DEFAULT_FEDERATE_VALUE = true;
* @returns rooms options
*/
export default class TchapCreateRoom {

static roomCreateOptions(
name: string,
tchapRoomType: TchapRoomType,
name: string,
tchapRoomType: TchapRoomType,
federate: boolean = DEFAULT_FEDERATE_VALUE): IOpts {
const opts: IOpts = {};
const createRoomOpts: ITchapCreateRoomOpts = {};
opts.createOpts = createRoomOpts;
const opts: IOpts = {};
const createRoomOpts: ITchapCreateRoomOpts = {};
opts.createOpts = createRoomOpts;

//tchap common options
createRoomOpts.name = name;
opts.guestAccess = false; //guest access are not authorized in tchap
//tchap common options
createRoomOpts.name = name;
opts.guestAccess = false; //guest access are not authorized in tchap

createRoomOpts.creation_content = { 'm.federate': federate };
createRoomOpts.creation_content = { 'm.federate': federate };

switch (tchapRoomType) {
case TchapRoomType.Forum: {
switch (tchapRoomType) {
case TchapRoomType.Forum: {
//"Forum" only for tchap members and not encrypted
createRoomOpts.accessRule = TchapRoomAccessRule.Restricted;
createRoomOpts.visibility = Visibility.Public;
createRoomOpts.preset = Preset.PublicChat;
opts.joinRule = JoinRule.Public;
opts.encryption = false;
opts.historyVisibility = HistoryVisibility.Shared;
break;
}
case TchapRoomType.Private: {
createRoomOpts.accessRule = TchapRoomAccessRule.Restricted;
createRoomOpts.visibility = Visibility.Public;
createRoomOpts.preset = Preset.PublicChat;
opts.joinRule = JoinRule.Public;
opts.encryption = false;
opts.historyVisibility = HistoryVisibility.Shared;
break;
}
case TchapRoomType.Private: {
//"Salon", only for tchap member and encrypted
createRoomOpts.accessRule = TchapRoomAccessRule.Restricted;
createRoomOpts.visibility = Visibility.Private;
createRoomOpts.preset = Preset.PrivateChat;
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
}
case TchapRoomType.External: {
createRoomOpts.accessRule = TchapRoomAccessRule.Restricted;
createRoomOpts.visibility = Visibility.Private;
createRoomOpts.preset = Preset.PrivateChat;
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
}
case TchapRoomType.External: {
//open to external and encrypted,
createRoomOpts.accessRule = TchapRoomAccessRule.Unrestricted;
createRoomOpts.visibility = Visibility.Private;
createRoomOpts.preset = Preset.PrivateChat;
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
createRoomOpts.accessRule = TchapRoomAccessRule.Unrestricted;
createRoomOpts.visibility = Visibility.Private;
createRoomOpts.preset = Preset.PrivateChat;
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
}
}
return opts;
}
return opts;
}
}
}

0 comments on commit 2519605

Please sign in to comment.