in-app-notification.ts 1.6 KB

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