in-app-notification.ts 1.4 KB

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