in-app-notification.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import type { IPageSnapshot } from '~/models/serializers/in-app-notification-snapshot/page';
  2. import { IPage } from './page';
  3. import { IUser } from './user';
  4. export enum InAppNotificationStatuses {
  5. STATUS_UNREAD = 'UNREAD',
  6. STATUS_UNOPENED = 'UNOPENED',
  7. STATUS_OPENED = 'OPENED',
  8. }
  9. export interface IInAppNotification {
  10. user: IUser
  11. targetModel: 'Page'
  12. target: IPage
  13. action: 'COMMENT' | 'LIKE'
  14. status: InAppNotificationStatuses
  15. actionUsers: IUser[]
  16. createdAt: Date
  17. snapshot: string
  18. parsedSnapshot?: IPageSnapshot
  19. }
  20. /*
  21. * Note:
  22. * Need to use mongoose PaginateResult as a type after upgrading mongoose v6.0.0.
  23. * Until then, use the original "PaginateResult".
  24. */
  25. export interface PaginateResult<T> {
  26. docs: T[];
  27. hasNextPage: boolean;
  28. hasPrevPage: boolean;
  29. limit: number;
  30. nextPage: number | null;
  31. offset: number;
  32. page: number;
  33. pagingCounter: number;
  34. prevPage: number | null;
  35. totalDocs: number;
  36. totalPages: number;
  37. }
  38. /*
  39. * In App Notification Settings
  40. */
  41. export enum subscribeRuleNames {
  42. PAGE_CREATE = 'PAGE_CREATE'
  43. }
  44. export enum SubscribeRuleDescriptions {
  45. PAGE_CREATE = 'in_app_notification_settings.default_subscribe_rules.page_create',
  46. }
  47. export interface ISubscribeRule {
  48. name: subscribeRuleNames;
  49. isEnabled: boolean;
  50. }
  51. export interface IInAppNotificationSettings<UserID> {
  52. userId: UserID | string;
  53. subscribeRules: ISubscribeRule[];
  54. }