Skip to content

Commit

Permalink
Merge pull request #27 from Automattic/team_sync_allow_membership_syn…
Browse files Browse the repository at this point in the history
…c_toggle_config

Allow membership sync to be disabled in team sync
  • Loading branch information
ashfame authored Nov 24, 2023
2 parents 8fe9837 + ae7741c commit d4b2383
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/TeamSyncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface ITeamSyncConfig {
alias_prefix?: string;
allow_private?: boolean;
allow_public?: boolean;
allow_membership_sync?: boolean;
hint_channel_admins?: boolean;
};
users?: {
Expand Down Expand Up @@ -78,6 +79,9 @@ export class TeamSyncer {
if (!teamConfig.channels.allow_public && !teamConfig.channels.allow_private) {
throw Error('At least one of allow_public, allow_private must be true in the teamSync config');
}
if (teamConfig.channels.allow_membership_sync === undefined) {
teamConfig.channels.allow_membership_sync = true;
}
// Send hint to channel admins
teamConfig.channels.hint_channel_admins =
teamConfig.channels.hint_channel_admins === undefined
Expand Down Expand Up @@ -433,6 +437,14 @@ export class TeamSyncer {
throw Error("Could not find team");
}

const config: false | ITeamSyncConfig = this.getTeamSyncConfig(teamId,"channel");
if (config) {
if (config.channels?.allow_membership_sync === false) {
log.info("Skipping membership sync because disabled in config");
return;
}
}

// create Set for both matrix membership state and slack membership state
// compare them to figure out who all needs to join the matrix room and leave the matrix room
// this obviously assumes we treat slack as the source of truth for membership
Expand Down

0 comments on commit d4b2383

Please sign in to comment.