@timardex/cluemart-server-shared 5.0.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -930,7 +930,8 @@ var baseResourceFields = {
930
930
 
931
931
  // src/mongoose/GoogleImportedMarket.ts
932
932
  import {
933
- EnumEventType
933
+ EnumEventType,
934
+ EnumImportedMarketDeactivationReason
934
935
  } from "@timardex/cluemart-shared";
935
936
  import mongoose10 from "mongoose";
936
937
 
@@ -1057,6 +1058,11 @@ var schema7 = new MongooseSchema6(
1057
1058
  type: ResourceImageTypeSchema
1058
1059
  },
1059
1060
  dateTime: [dateTimeSchema],
1061
+ deactivatedReason: {
1062
+ enum: Object.values(EnumImportedMarketDeactivationReason),
1063
+ required: false,
1064
+ type: String
1065
+ },
1060
1066
  deletedAt: { default: null, required: false, type: Date },
1061
1067
  description: { required: true, type: String },
1062
1068
  earliestStartDate: { default: null, required: false, type: Date },
@@ -1111,7 +1117,7 @@ var GoogleImportedMarketModel = mongoose10.models.GoogleImportedMarket || mongoo
1111
1117
  // src/mongoose/AiImportedMarket.ts
1112
1118
  import {
1113
1119
  EnumEventType as EnumEventType2,
1114
- EnumImportedMarketDeactivationReason,
1120
+ EnumImportedMarketDeactivationReason as EnumImportedMarketDeactivationReason2,
1115
1121
  EnumImportedMarketReviewStatus
1116
1122
  } from "@timardex/cluemart-shared";
1117
1123
  import mongoose11 from "mongoose";
@@ -1144,7 +1150,7 @@ var schema8 = new MongooseSchema7(
1144
1150
  },
1145
1151
  dateTime: [dateTimeSchema],
1146
1152
  deactivatedReason: {
1147
- enum: Object.values(EnumImportedMarketDeactivationReason),
1153
+ enum: Object.values(EnumImportedMarketDeactivationReason2),
1148
1154
  required: false,
1149
1155
  type: String
1150
1156
  },
@@ -2096,8 +2102,11 @@ var schema17 = new MongooseSchema18(
2096
2102
  categories: { required: true, type: [CategorySchema] },
2097
2103
  categoriesNames: { default: [], required: false, type: [String] },
2098
2104
  claimed: { default: true, required: false, type: Boolean },
2105
+ downgradeNotifiedAt: { default: null, required: false, type: Date },
2099
2106
  downgradeSnapshot: { required: false, type: downgradeSnapshotSchema },
2107
+ featuresDowngraded: { default: false, required: false, type: Boolean },
2100
2108
  foodTruck: { required: true, type: Boolean },
2109
+ licenceEpoch: { default: 0, required: false, type: Number },
2101
2110
  products: { required: false, type: productWrapperSchema },
2102
2111
  shareRelation: { required: false, type: socialShareResourceSchema },
2103
2112
  unregisteredVendorId: {
@@ -3457,6 +3466,38 @@ var ASSOCIABLE_MODELS = {
3457
3466
  [EnumResourceType10.PARTNER]: PartnerModel,
3458
3467
  [EnumResourceType10.VENDOR]: VendorModel
3459
3468
  };
3469
+ function pinAssociateTimestamp(value) {
3470
+ return value == null ? null : { $in: [value, null] };
3471
+ }
3472
+ function buildAssociatesWriteGuard({
3473
+ canManage,
3474
+ nextAssociates,
3475
+ snapshot
3476
+ }) {
3477
+ if (!canManage) {
3478
+ return null;
3479
+ }
3480
+ const previous = snapshot ?? [];
3481
+ const emptyListFilter = {
3482
+ $or: [{ associates: { $size: 0 } }, { associates: null }]
3483
+ };
3484
+ return {
3485
+ filter: previous.length > 0 ? {
3486
+ $and: previous.map((associate) => ({
3487
+ associates: {
3488
+ $elemMatch: {
3489
+ addedAt: pinAssociateTimestamp(associate.addedAt),
3490
+ respondedAt: pinAssociateTimestamp(associate.respondedAt),
3491
+ status: associate.status,
3492
+ userId: associate.userId
3493
+ }
3494
+ }
3495
+ })),
3496
+ associates: { $size: previous.length }
3497
+ } : emptyListFilter,
3498
+ update: { associates: nextAssociates }
3499
+ };
3500
+ }
3460
3501
  function acceptedAssociateUserIds(associates) {
3461
3502
  return (associates ?? []).filter((associate) => associate.status === EnumAssociateStatus2.ACCEPTED).map((associate) => associate.userId);
3462
3503
  }
@@ -3496,7 +3537,10 @@ async function acceptedUserIdsForResource({
3496
3537
  resourceType
3497
3538
  }) {
3498
3539
  const model = ASSOCIABLE_MODELS[resourceType];
3499
- const resource = await model.findOne({ _id: resourceId, deletedAt: null }).select("associates").lean().exec();
3540
+ const resource = await model.findOne({ _id: resourceId, deletedAt: null }).select("associates featuresDowngraded").lean().exec();
3541
+ if (resource?.featuresDowngraded) {
3542
+ return /* @__PURE__ */ new Set();
3543
+ }
3500
3544
  return new Set(
3501
3545
  acceptedAssociateUserIds(resource?.associates).map(
3502
3546
  (userId) => String(userId)
@@ -3646,12 +3690,12 @@ async function reconcileUserBatch({
3646
3690
  _id: {
3647
3691
  $in: [...heldByResource.values()].map((entry) => entry.resourceId)
3648
3692
  }
3649
- }).select("associates deletedAt").lean().exec();
3693
+ }).select("associates deletedAt featuresDowngraded").lean().exec();
3650
3694
  const acceptedByResource = /* @__PURE__ */ new Map();
3651
3695
  for (const resource of resources) {
3652
3696
  acceptedByResource.set(
3653
3697
  String(resource._id),
3654
- resource.deletedAt ? /* @__PURE__ */ new Set() : new Set(
3698
+ resource.deletedAt || resource.featuresDowngraded ? /* @__PURE__ */ new Set() : new Set(
3655
3699
  acceptedAssociateUserIds(resource.associates).map(
3656
3700
  (userId) => String(userId)
3657
3701
  )
@@ -4744,17 +4788,19 @@ import {
4744
4788
  EnumSubscriptionStatus as EnumSubscriptionStatus3,
4745
4789
  EnumUserLicence as EnumUserLicence8,
4746
4790
  isNonVisitorResourceType,
4791
+ isProLicenceType,
4792
+ isStandardLicenceType,
4747
4793
  LicenceExpiryDate
4748
4794
  } from "@timardex/cluemart-shared";
4749
4795
  import dayjs5 from "dayjs";
4750
4796
  import { GraphQLError } from "graphql";
4751
- var LicenceCategory = /* @__PURE__ */ ((LicenceCategory3) => {
4752
- LicenceCategory3["EVENT"] = "event";
4753
- LicenceCategory3["PARTNER"] = "partner";
4754
- LicenceCategory3["VENDOR"] = "vendor";
4755
- LicenceCategory3["AFFILIATE"] = "affiliate";
4756
- LicenceCategory3["SCHOOL"] = "school";
4757
- return LicenceCategory3;
4797
+ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
4798
+ LicenceCategory2["EVENT"] = "event";
4799
+ LicenceCategory2["PARTNER"] = "partner";
4800
+ LicenceCategory2["VENDOR"] = "vendor";
4801
+ LicenceCategory2["AFFILIATE"] = "affiliate";
4802
+ LicenceCategory2["SCHOOL"] = "school";
4803
+ return LicenceCategory2;
4758
4804
  })(LicenceCategory || {});
4759
4805
  var licenceCategoryMapping = {
4760
4806
  [EnumUserLicence8.PRO_EVENT]: "event" /* EVENT */,
@@ -4778,25 +4824,8 @@ var licencePriority = {
4778
4824
  [EnumUserLicence8.STANDARD_AFFILIATE]: 1,
4779
4825
  [EnumUserLicence8.STANDARD_SCHOOL]: 1
4780
4826
  };
4781
- var standardLicences = [
4782
- EnumUserLicence8.STANDARD_VENDOR,
4783
- EnumUserLicence8.STANDARD_EVENT,
4784
- EnumUserLicence8.STANDARD_PARTNER
4785
- ];
4786
- var standardLicenceSet = new Set(standardLicences);
4787
- function isStandardLicence(licence) {
4788
- return standardLicenceSet.has(licence);
4789
- }
4790
- var proLicences = [
4791
- EnumUserLicence8.PRO_EVENT,
4792
- EnumUserLicence8.PRO_PLUS_EVENT,
4793
- EnumUserLicence8.PRO_VENDOR,
4794
- EnumUserLicence8.PRO_PLUS_VENDOR
4795
- ];
4796
- var proLicenceSet = new Set(proLicences);
4797
- function isProLicence(licence) {
4798
- return proLicenceSet.has(licence);
4799
- }
4827
+ var isStandardLicence = isStandardLicenceType;
4828
+ var isProLicence = isProLicenceType;
4800
4829
  var categoryRegexMapping = {
4801
4830
  ["event" /* EVENT */]: /_event$/,
4802
4831
  ["partner" /* PARTNER */]: /_partner$/,
@@ -5119,30 +5148,134 @@ async function findUserVendor(userId, logLabel) {
5119
5148
  }
5120
5149
  return vendor;
5121
5150
  }
5151
+ async function downgradeStillApplies(ownerUserId) {
5152
+ const hasActiveProLicence = await hasActiveProLicenceForResource({
5153
+ includeStripeProtected: true,
5154
+ resourceType: EnumResourceType12.VENDOR,
5155
+ userId: ownerUserId
5156
+ });
5157
+ return !hasActiveProLicence;
5158
+ }
5122
5159
  async function applyVendorDowngrade(vendor, ownerUserId) {
5123
- const updateData = {};
5124
- updateData.availability = {
5125
- corporate: false,
5126
- private: false,
5127
- school: false
5128
- };
5129
- updateData.products = {
5130
- active: false,
5131
- productsList: vendor.products?.productsList ?? []
5132
- };
5133
- updateData.calendar = {
5134
- active: false,
5135
- calendarData: vendor.calendar?.calendarData ?? []
5136
- };
5137
- updateData.downgradeSnapshot = {
5138
- availability: vendor.availability,
5139
- calendarActive: vendor.calendar?.active,
5140
- productsActive: vendor.products?.active
5160
+ let current = vendor;
5161
+ for (let attempt = 0; attempt < 2; attempt += 1) {
5162
+ if (!await downgradeStillApplies(ownerUserId)) {
5163
+ console.info(
5164
+ "[applyVendorDowngrade] owner holds an active PRO licence again; skipping the downgrade",
5165
+ { vendorId: String(current._id) }
5166
+ );
5167
+ return "skipped";
5168
+ }
5169
+ const associatesGuard = buildAssociatesWriteGuard({
5170
+ canManage: true,
5171
+ nextAssociates: [],
5172
+ snapshot: current.associates
5173
+ });
5174
+ if (!associatesGuard) {
5175
+ return "skipped";
5176
+ }
5177
+ const result = await VendorModel.updateOne(
5178
+ {
5179
+ _id: current._id,
5180
+ active: true,
5181
+ deletedAt: null,
5182
+ // Already downgraded: another run got there first and its snapshot is
5183
+ // the original state this one must not overwrite.
5184
+ featuresDowngraded: { $ne: true },
5185
+ // Upgrades bump this in their own write; `null` covers vendors that
5186
+ // predate the field.
5187
+ licenceEpoch: { $in: [current.licenceEpoch ?? 0, null] },
5188
+ "owner.userId": ownerUserId,
5189
+ ...associatesGuard.filter
5190
+ },
5191
+ {
5192
+ $inc: { licenceEpoch: 1 },
5193
+ $set: {
5194
+ ...associatesGuard.update,
5195
+ availability: {
5196
+ corporate: false,
5197
+ private: false,
5198
+ school: false
5199
+ },
5200
+ calendar: {
5201
+ active: false,
5202
+ calendarData: current.calendar?.calendarData ?? []
5203
+ },
5204
+ downgradeSnapshot: {
5205
+ availability: current.availability,
5206
+ calendarActive: current.calendar?.active,
5207
+ productsActive: current.products?.active
5208
+ },
5209
+ featuresDowngraded: true,
5210
+ // STANDARD_VENDOR keeps only the first 6 images active.
5211
+ images: (current.images ?? []).map((image, index) => ({
5212
+ ...image,
5213
+ active: index < 6
5214
+ })),
5215
+ products: {
5216
+ active: false,
5217
+ productsList: current.products?.productsList ?? []
5218
+ }
5219
+ }
5220
+ }
5221
+ );
5222
+ if ((result?.matchedCount ?? 0) > 0) {
5223
+ break;
5224
+ }
5225
+ const fresh = await VendorModel.findById(current._id).lean().exec();
5226
+ if (!fresh) {
5227
+ return "skipped";
5228
+ }
5229
+ if (fresh.featuresDowngraded === true) {
5230
+ console.info(
5231
+ "[applyVendorDowngrade] vendor is already downgraded; licence sync can proceed",
5232
+ { vendorId: String(fresh._id) }
5233
+ );
5234
+ return "already-downgraded";
5235
+ }
5236
+ current = fresh;
5237
+ if (attempt === 1) {
5238
+ console.warn(
5239
+ "[applyVendorDowngrade] vendor changed under the downgrade; left to the next compliance run",
5240
+ { vendorId: String(current._id) }
5241
+ );
5242
+ return "skipped";
5243
+ }
5244
+ }
5245
+ try {
5246
+ await detachStaleAssociateGrants({
5247
+ acceptedUserIds: [],
5248
+ resourceId: current._id,
5249
+ resourceType: EnumResourceType12.VENDOR
5250
+ });
5251
+ } catch (error) {
5252
+ console.error(
5253
+ "[applyVendorDowngrade] grant detach failed; left to reconciliation",
5254
+ error
5255
+ );
5256
+ }
5257
+ return "applied";
5258
+ }
5259
+ async function applyVendorRestore(vendor, ownerUserId) {
5260
+ const snapshot = vendor.downgradeSnapshot;
5261
+ const updateData = {
5262
+ availability: {
5263
+ corporate: snapshot?.availability?.corporate ?? true,
5264
+ private: snapshot?.availability?.private ?? true,
5265
+ school: snapshot?.availability?.school ?? true
5266
+ },
5267
+ calendar: {
5268
+ active: snapshot?.calendarActive ?? true,
5269
+ calendarData: vendor.calendar?.calendarData ?? []
5270
+ },
5271
+ downgradeNotifiedAt: null,
5272
+ featuresDowngraded: false,
5273
+ images: (vendor.images ?? []).map((image) => ({ ...image, active: true })),
5274
+ products: {
5275
+ active: snapshot?.productsActive ?? true,
5276
+ productsList: vendor.products?.productsList ?? []
5277
+ }
5141
5278
  };
5142
- updateData.images = (vendor.images ?? []).map((image, index) => ({
5143
- ...image,
5144
- active: index < 6
5145
- }));
5146
5279
  const result = await VendorModel.updateOne(
5147
5280
  {
5148
5281
  _id: vendor._id,
@@ -5150,7 +5283,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
5150
5283
  deletedAt: null,
5151
5284
  "owner.userId": ownerUserId
5152
5285
  },
5153
- { $set: updateData }
5286
+ { $inc: { licenceEpoch: 1 }, $set: updateData }
5154
5287
  );
5155
5288
  return (result?.matchedCount ?? 0) > 0;
5156
5289
  }
@@ -5170,37 +5303,6 @@ async function downgradeVendorProFeatures(userId, licenceType) {
5170
5303
  throw error;
5171
5304
  }
5172
5305
  }
5173
- async function applyVendorRestore(vendor, ownerUserId) {
5174
- const updateData = {};
5175
- const snapshot = vendor.downgradeSnapshot;
5176
- updateData.availability = {
5177
- corporate: snapshot?.availability?.corporate ?? true,
5178
- private: snapshot?.availability?.private ?? true,
5179
- school: snapshot?.availability?.school ?? true
5180
- };
5181
- updateData.products = {
5182
- active: snapshot?.productsActive ?? true,
5183
- productsList: vendor.products?.productsList ?? []
5184
- };
5185
- updateData.calendar = {
5186
- active: snapshot?.calendarActive ?? true,
5187
- calendarData: vendor.calendar?.calendarData ?? []
5188
- };
5189
- updateData.images = (vendor.images ?? []).map((image) => ({
5190
- ...image,
5191
- active: true
5192
- }));
5193
- const result = await VendorModel.updateOne(
5194
- {
5195
- _id: vendor._id,
5196
- active: true,
5197
- deletedAt: null,
5198
- "owner.userId": ownerUserId
5199
- },
5200
- { $set: updateData }
5201
- );
5202
- return (result?.matchedCount ?? 0) > 0;
5203
- }
5204
5306
  async function restoreVendorProFeatures(userId, licenceType) {
5205
5307
  const isProVendor = licenceType === EnumUserLicence9.PRO_VENDOR || licenceType === EnumUserLicence9.PRO_PLUS_VENDOR;
5206
5308
  if (!isProVendor) {
@@ -5217,6 +5319,61 @@ async function restoreVendorProFeatures(userId, licenceType) {
5217
5319
  throw error;
5218
5320
  }
5219
5321
  }
5322
+ var NOTIFICATION_CLAIM_LEASE_MS = 60 * 60 * 1e3;
5323
+ async function notifyVendorDowngrade(vendorId, ownerUserId) {
5324
+ if (!await downgradeStillApplies(ownerUserId)) {
5325
+ return false;
5326
+ }
5327
+ const claimedAt = /* @__PURE__ */ new Date();
5328
+ const claimed = await VendorModel.findOneAndUpdate(
5329
+ {
5330
+ $or: [
5331
+ { downgradeNotifiedAt: null },
5332
+ {
5333
+ downgradeNotifiedAt: {
5334
+ $lt: new Date(claimedAt.getTime() - NOTIFICATION_CLAIM_LEASE_MS)
5335
+ }
5336
+ }
5337
+ ],
5338
+ _id: vendorId,
5339
+ active: true,
5340
+ deletedAt: null,
5341
+ // A re-upgrade that restored the vendor has flipped this back, so its
5342
+ // owner is not told about a downgrade that no longer holds.
5343
+ featuresDowngraded: true
5344
+ },
5345
+ { $set: { downgradeNotifiedAt: claimedAt } },
5346
+ { new: false }
5347
+ ).lean().exec();
5348
+ if (!claimed) {
5349
+ return false;
5350
+ }
5351
+ const sent = await sendDeactivationNotification(
5352
+ {
5353
+ data: {
5354
+ resourceId: String(claimed._id),
5355
+ resourceName: claimed.name,
5356
+ resourceType: EnumNotificationResourceType4.DOWNGRADED_VENDOR
5357
+ },
5358
+ message: `Your Vendor licence has been downgraded due to licence expiration.`,
5359
+ title: `Vendor Licence Downgraded`,
5360
+ type: EnumNotificationType3.SYSTEM,
5361
+ userIds: [ownerUserId]
5362
+ },
5363
+ ownerUserId,
5364
+ claimed.name,
5365
+ "vendor",
5366
+ claimed.downgradeNotifiedAt ?? null
5367
+ );
5368
+ if (sent) {
5369
+ return true;
5370
+ }
5371
+ await VendorModel.updateOne(
5372
+ { _id: vendorId, downgradeNotifiedAt: claimedAt },
5373
+ { $set: { downgradeNotifiedAt: null } }
5374
+ );
5375
+ return false;
5376
+ }
5220
5377
  async function handleVendorLicenceCompliance(user, now) {
5221
5378
  if (!user.licences || !user.vendor) {
5222
5379
  return;
@@ -5227,10 +5384,10 @@ async function handleVendorLicenceCompliance(user, now) {
5227
5384
  if (vendorLicencesOfUser.length === 0) {
5228
5385
  return;
5229
5386
  }
5230
- const proLicences2 = vendorLicencesOfUser.filter(
5387
+ const proLicences = vendorLicencesOfUser.filter(
5231
5388
  (licence) => licence.licenceType !== EnumUserLicence9.STANDARD_VENDOR
5232
5389
  );
5233
- const expiredProLicences = proLicences2.filter(
5390
+ const expiredProLicences = proLicences.filter(
5234
5391
  (licence) => !dayjs6(licence.expiryDate).isAfter(now)
5235
5392
  );
5236
5393
  const stripeProtectedLicenceTypes = new Set(
@@ -5241,7 +5398,7 @@ async function handleVendorLicenceCompliance(user, now) {
5241
5398
  const expiredProLicence = expiredProLicences.some(
5242
5399
  (licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
5243
5400
  );
5244
- const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences2, vendorLicences, now);
5401
+ const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, vendorLicences, now);
5245
5402
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
5246
5403
  (licence) => !dayjs6(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
5247
5404
  );
@@ -5257,29 +5414,27 @@ async function handleVendorLicenceCompliance(user, now) {
5257
5414
  "owner.userId": user._id
5258
5415
  }).lean().exec();
5259
5416
  }
5417
+ const needsDowngrade = expiredProLicence && Boolean(vendor) && !hasValidProLicence;
5418
+ const outcome = needsDowngrade && vendor ? await applyVendorDowngrade(vendor, user._id) : "skipped";
5260
5419
  const licencesToSync = vendorLicences.filter(
5261
5420
  (licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
5262
5421
  );
5263
- await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
5264
- if (!expiredProLicence || !vendor || hasValidProLicence) {
5422
+ if (!needsDowngrade) {
5423
+ await syncUserLicencesAfterExpiry(
5424
+ user._id,
5425
+ licencesToSync,
5426
+ now,
5427
+ "downgrade"
5428
+ );
5265
5429
  return;
5266
5430
  }
5267
- const downgraded = await applyVendorDowngrade(vendor, user._id);
5268
- if (!downgraded) {
5431
+ if (outcome === "skipped" || !vendor) {
5269
5432
  return;
5270
5433
  }
5271
- const payload = {
5272
- data: {
5273
- resourceId: String(vendor._id),
5274
- resourceName: vendor.name,
5275
- resourceType: EnumNotificationResourceType4.DOWNGRADED_VENDOR
5276
- },
5277
- message: `Your Vendor licence has been downgraded due to licence expiration.`,
5278
- title: `Vendor Licence Downgraded`,
5279
- type: EnumNotificationType3.SYSTEM,
5280
- userIds: [user._id]
5281
- };
5282
- await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
5434
+ if (!await notifyVendorDowngrade(vendor._id, user._id)) {
5435
+ return;
5436
+ }
5437
+ await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
5283
5438
  }
5284
5439
  async function vendorOwnerHasProLicence(vendorId) {
5285
5440
  const vendor = await VendorModel.findOne({
@@ -5324,17 +5479,35 @@ function hasValidLicence(licences, licenceTypes, now) {
5324
5479
  (licence) => licenceTypes.includes(licence.licenceType) && dayjs7(licence.expiryDate).isAfter(now)
5325
5480
  );
5326
5481
  }
5327
- async function sendDeactivationNotification(payload, userId, resourceName, resourceType) {
5482
+ async function deactivationNoticeStored(payload, userId, since) {
5483
+ const stored = await NotificationModel.exists({
5484
+ createdAt: { $gte: since },
5485
+ "data.resourceId": payload.data.resourceId,
5486
+ "data.resourceType": payload.data.resourceType,
5487
+ title: payload.title,
5488
+ type: payload.type,
5489
+ userId
5490
+ });
5491
+ return stored !== null;
5492
+ }
5493
+ async function sendDeactivationNotification(payload, userId, resourceName, resourceType, retryOf = null) {
5494
+ if (retryOf && await deactivationNoticeStored(payload, userId, retryOf)) {
5495
+ console.log(
5496
+ `\u{1F501} ${resourceType} notification already stored for user ${String(userId)} for "${resourceName}"`
5497
+ );
5498
+ return true;
5499
+ }
5328
5500
  const sent = await notifyUsers({ payload });
5329
5501
  if (!sent) {
5330
5502
  console.error(
5331
5503
  `\u274C ${resourceType} notification not confirmed for user ${String(userId)} for "${resourceName}"`
5332
5504
  );
5333
- return;
5505
+ return false;
5334
5506
  }
5335
5507
  console.log(
5336
5508
  `\u2705 Sent ${resourceType} notification to user ${String(userId)} for "${resourceName}"`
5337
5509
  );
5510
+ return true;
5338
5511
  }
5339
5512
  async function processUserCompliance(user, now) {
5340
5513
  if (!user.licences) {
@@ -5767,6 +5940,7 @@ export {
5767
5940
  activeAffiliateCodeExists,
5768
5941
  awardAffiliateVendorSubscriptionRewards,
5769
5942
  baseResourceFields,
5943
+ buildAssociatesWriteGuard,
5770
5944
  buildInitialBillingCatalogEntries,
5771
5945
  buildLicenceExpiryPipeline,
5772
5946
  buildUserHasEnoughPointsFilter,
@@ -5831,6 +6005,7 @@ export {
5831
6005
  notifyUsers,
5832
6006
  partnerLicences,
5833
6007
  persistArchivedEventDates,
6008
+ pinAssociateTimestamp,
5834
6009
  processLicenseReminder,
5835
6010
  processUserCompliance,
5836
6011
  processUserLicenseReminders,