{"version":3,"sources":["../src/NotificationServicesController/processors/process-feature-announcement.ts"],"sourcesContent":["import type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type { INotification } from '../types/notification/notification';\n\nconst ONE_DAY_MS = 1000 * 60 * 60 * 24;\n\nconst shouldAutoExpire = (oldDate: Date) => {\n  const differenceInTime = Date.now() - oldDate.getTime();\n  const differenceInDays = differenceInTime / ONE_DAY_MS;\n  return differenceInDays >= 90;\n};\n\n/**\n * Checks if a feature announcement should be read.\n * Checks feature announcement state (from param), as well as if the notification is \"expired\"\n *\n * @param notification - notification to check\n * @param readPlatformNotificationsList - list of read notifications\n * @returns boolean if notification should be marked as read or unread\n */\nexport function isFeatureAnnouncementRead(\n  notification: Pick<INotification, 'id' | 'createdAt'>,\n  readPlatformNotificationsList: string[],\n): boolean {\n  if (readPlatformNotificationsList.includes(notification.id)) {\n    return true;\n  }\n  return shouldAutoExpire(new Date(notification.createdAt));\n}\n\n/**\n * Processes a feature announcement into a shared/normalised notification shape.\n *\n * @param notification - raw feature announcement\n * @returns a normalised feature announcement\n */\nexport function processFeatureAnnouncement(\n  notification: FeatureAnnouncementRawNotification,\n): INotification {\n  return {\n    type: notification.type,\n    id: notification.data.id,\n    createdAt: new Date(notification.createdAt).toISOString(),\n    data: notification.data,\n    isRead: false,\n  };\n}\n"],"mappings":";AAGA,IAAM,aAAa,MAAO,KAAK,KAAK;AAEpC,IAAM,mBAAmB,CAAC,YAAkB;AAC1C,QAAM,mBAAmB,KAAK,IAAI,IAAI,QAAQ,QAAQ;AACtD,QAAM,mBAAmB,mBAAmB;AAC5C,SAAO,oBAAoB;AAC7B;AAUO,SAAS,0BACd,cACA,+BACS;AACT,MAAI,8BAA8B,SAAS,aAAa,EAAE,GAAG;AAC3D,WAAO;AAAA,EACT;AACA,SAAO,iBAAiB,IAAI,KAAK,aAAa,SAAS,CAAC;AAC1D;AAQO,SAAS,2BACd,cACe;AACf,SAAO;AAAA,IACL,MAAM,aAAa;AAAA,IACnB,IAAI,aAAa,KAAK;AAAA,IACtB,WAAW,IAAI,KAAK,aAAa,SAAS,EAAE,YAAY;AAAA,IACxD,MAAM,aAAa;AAAA,IACnB,QAAQ;AAAA,EACV;AACF;","names":[]}