mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
add: more commits
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -28,7 +28,7 @@ const mdl_UserTiers = require('../../models/tiers/user_tiers.mdl');
|
||||
const mdl_TierPlans = require('../../models/tiers/tier_plans.mdl');
|
||||
const UserNotification = require('../../models/notifications/user_notification.mdl');
|
||||
const CronNotificationSetting = require('../../models/notifications/cron_notification_setting.mdl');
|
||||
const { NOTIFICATION_REGISTRY } = require('../../data/notifications.data');
|
||||
const { getNotificationTemplate, renderNotificationContent } = require('../../services/notificationTemplate.service');
|
||||
|
||||
require('../../models/tiers/tier.associations');
|
||||
|
||||
@@ -73,18 +73,17 @@ async function run() {
|
||||
// Status flip above always happens — only this step is skippable via settings.
|
||||
const settings = await CronNotificationSetting.findOne({ where: { job_name: 'expireUserTiers' } });
|
||||
if (!settings || settings.enabled) {
|
||||
const notifications = expired.map((t) =>
|
||||
NOTIFICATION_REGISTRY.tier_expired.build({
|
||||
tier: t.tier,
|
||||
label: t.plan?.label ?? null,
|
||||
planId: t.plan?.plan_id ?? null,
|
||||
})
|
||||
).map((payload, i) => ({
|
||||
user_id: expired[i].user_id,
|
||||
...payload,
|
||||
}));
|
||||
|
||||
try {
|
||||
const template = await getNotificationTemplate('tier_expired');
|
||||
const notifications = expired.map((t) => ({
|
||||
user_id: t.user_id,
|
||||
...renderNotificationContent(template, {
|
||||
tier: t.tier,
|
||||
label: t.plan?.label ?? null,
|
||||
planId: t.plan?.plan_id ?? null,
|
||||
}),
|
||||
}));
|
||||
|
||||
await UserNotification.bulkCreate(notifications, { ignoreDuplicates: true });
|
||||
} catch (err) {
|
||||
console.error('[CRON][EXPIRE TIERS] Notification bulkCreate failed:', err);
|
||||
|
||||
Reference in New Issue
Block a user