Skip to content

Commit d4b2383

Browse files
authored
Merge pull request #27 from Automattic/team_sync_allow_membership_sync_toggle_config
Allow membership sync to be disabled in team sync
2 parents 8fe9837 + ae7741c commit d4b2383

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/TeamSyncer.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface ITeamSyncConfig {
3636
alias_prefix?: string;
3737
allow_private?: boolean;
3838
allow_public?: boolean;
39+
allow_membership_sync?: boolean;
3940
hint_channel_admins?: boolean;
4041
};
4142
users?: {
@@ -78,6 +79,9 @@ export class TeamSyncer {
7879
if (!teamConfig.channels.allow_public && !teamConfig.channels.allow_private) {
7980
throw Error('At least one of allow_public, allow_private must be true in the teamSync config');
8081
}
82+
if (teamConfig.channels.allow_membership_sync === undefined) {
83+
teamConfig.channels.allow_membership_sync = true;
84+
}
8185
// Send hint to channel admins
8286
teamConfig.channels.hint_channel_admins =
8387
teamConfig.channels.hint_channel_admins === undefined
@@ -433,6 +437,14 @@ export class TeamSyncer {
433437
throw Error("Could not find team");
434438
}
435439

440+
const config: false | ITeamSyncConfig = this.getTeamSyncConfig(teamId,"channel");
441+
if (config) {
442+
if (config.channels?.allow_membership_sync === false) {
443+
log.info("Skipping membership sync because disabled in config");
444+
return;
445+
}
446+
}
447+
436448
// create Set for both matrix membership state and slack membership state
437449
// compare them to figure out who all needs to join the matrix room and leave the matrix room
438450
// this obviously assumes we treat slack as the source of truth for membership

0 commit comments

Comments
 (0)