in-app-notification.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import type { IUser } from '@growi/core';
  2. import type { SupportedTargetModelType, SupportedActionType } from './activity';
  3. export enum InAppNotificationStatuses {
  4. STATUS_UNOPENED = 'UNOPENED',
  5. STATUS_OPENED = 'OPENED',
  6. }
  7. export interface IInAppNotification<T = unknown> {
  8. user: IUser
  9. targetModel: SupportedTargetModelType
  10. target: T
  11. action: SupportedActionType
  12. status: InAppNotificationStatuses
  13. actionUsers: IUser[]
  14. createdAt: Date
  15. snapshot: string
  16. parsedSnapshot?: any
  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. }