refactor: modularize notification job creation and enforce plan-based channel availability in policy resolver
This commit is contained in:
@@ -93,6 +93,21 @@ export class PolicyResolver {
|
||||
};
|
||||
}
|
||||
|
||||
async resolveAvailableChannels(
|
||||
companyId: string,
|
||||
channels: NotificationChannel[]
|
||||
): Promise<NotificationChannel[]> {
|
||||
const companyPolicy = await this.companyPolicyAdapter.findOne({ companyId });
|
||||
const enabledChannels = companyPolicy
|
||||
? companyPolicy.defaultChannels
|
||||
: SYSTEM_DEFAULT_CHANNELS;
|
||||
const companyEnabledChannels = channels.filter((channel) =>
|
||||
enabledChannels.includes(channel)
|
||||
);
|
||||
|
||||
return this.applyPlanLimits(companyId, companyEnabledChannels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns muted channels from the winning cascade level only.
|
||||
* Per spec, muted channels are NOT merged across levels.
|
||||
|
||||
Reference in New Issue
Block a user