in-app-notification.ts 1.2 KB

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