GlobalNotificationSetting.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { Model } from 'mongoose';
  2. import mongoose from 'mongoose';
  3. import type Crowi from '~/server/crowi';
  4. import {
  5. class as GlobalNotificationSettingClass,
  6. type GlobalNotificationSettingModel,
  7. schema as GlobalNotificationSettingSchema,
  8. type IGlobalNotificationSetting,
  9. } from './GlobalNotificationSetting/index';
  10. /**
  11. * global notifcation event master
  12. */
  13. export const GlobalNotificationSettingEvent = {
  14. PAGE_CREATE: 'pageCreate',
  15. PAGE_EDIT: 'pageEdit',
  16. PAGE_DELETE: 'pageDelete',
  17. PAGE_MOVE: 'pageMove',
  18. PAGE_LIKE: 'pageLike',
  19. COMMENT: 'comment',
  20. } as const;
  21. /**
  22. * global notifcation type master
  23. */
  24. export const GlobalNotificationSettingType = {
  25. MAIL: 'mail',
  26. SLACK: 'slack',
  27. } as const;
  28. const factory = (crowi: Crowi): GlobalNotificationSettingModel => {
  29. GlobalNotificationSettingClass.crowi = crowi;
  30. GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
  31. return mongoose.model<
  32. IGlobalNotificationSetting,
  33. GlobalNotificationSettingModel
  34. >('GlobalNotificationSetting', GlobalNotificationSettingSchema);
  35. };
  36. export default factory;