2
0

in-app-notification.ts 1.3 KB

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