sou 7 лет назад
Родитель
Сommit
9210493812

+ 4 - 5
lib/models/GlobalNotificationSetting.js

@@ -1,7 +1,6 @@
 const debug = require('debug')('growi:models:GlobalNotificationSetting');
 const mongoose = require('mongoose');
-const notificationSchema = require('./GlobalNotificationSetting/GlobalNotificationSettingParentSchema');
-const GlobalNotificationSettingClass = require('./GlobalNotificationSetting/GlobalNotificationSettingClass');
+const GlobalNotificationSetting = require('./GlobalNotificationSetting/index');
 
 /**
  * create child schemas inherited from parentSchema
@@ -20,7 +19,7 @@ const createChildSchemas = (parentSchema, modelName, discriminatorKey) => {
 };
 
 module.exports = function(crowi) {
-  GlobalNotificationSettingClass.crowi = crowi;
-  notificationSchema.loadClass(GlobalNotificationSettingClass);
-  return createChildSchemas(notificationSchema, 'GlobalNotificationSetting', 'type');
+  GlobalNotificationSetting.class.crowi = crowi;
+  GlobalNotificationSetting.schema.loadClass(GlobalNotificationSetting.class);
+  return createChildSchemas(GlobalNotificationSetting.schema, 'GlobalNotificationSetting', 'type');
 };

+ 4 - 5
lib/models/GlobalNotificationSetting/GlobalNotificationMailSetting.js

@@ -1,6 +1,5 @@
 const mongoose = require('mongoose');
-const notificationSchema = require('./GlobalNotificationSettingParentSchema');
-const GlobalNotificationSettingClass = require('./GlobalNotificationSettingClass');
+const GlobalNotificationSetting = require('./index');
 
 /**
  * create child schemas inherited from parentSchema
@@ -20,7 +19,7 @@ const createChildSchemas = (parentSchema, modelName, discriminatorKey) => {
 };
 
 module.exports = function(crowi) {
-  GlobalNotificationSettingClass.crowi = crowi;
-  notificationSchema.loadClass(GlobalNotificationSettingClass);
-  return createChildSchemas(notificationSchema, 'GlobalNotificationSetting', 'type');
+  GlobalNotificationSetting.class.crowi = crowi;
+  GlobalNotificationSetting.schema.loadClass(GlobalNotificationSetting.class);
+  return createChildSchemas(GlobalNotificationSetting.schema, 'GlobalNotificationSetting', 'type');
 };

+ 0 - 12
lib/models/GlobalNotificationSetting/GlobalNotificationSettingParentSchema.js

@@ -1,12 +0,0 @@
-const mongoose = require('mongoose');
-
-/**
- * parent schema for GlobalNotificationSetting model
- */
-const globalNotificationSettingSchema = new mongoose.Schema({
-  isEnabled: { type: Boolean, required: true, default: true },
-  triggerPath: { type: String, required: true },
-  triggerEvents: { type: [String] },
-});
-
-module.exports = globalNotificationSettingSchema;

+ 4 - 5
lib/models/GlobalNotificationSetting/GlobalNotificationSlackSetting.js

@@ -1,6 +1,5 @@
 const mongoose = require('mongoose');
-const notificationSchema = require('./GlobalNotificationSettingParentSchema');
-const GlobalNotificationSettingClass = require('./GlobalNotificationSettingClass');
+const GlobalNotificationSetting = require('./index');
 
 /**
  * create child schemas inherited from parentSchema
@@ -20,7 +19,7 @@ const createChildSchemas = (parentSchema, modelName, discriminatorKey) => {
 };
 
 module.exports = function(crowi) {
-  GlobalNotificationSettingClass.crowi = crowi;
-  notificationSchema.loadClass(GlobalNotificationSettingClass);
-  return createChildSchemas(notificationSchema, 'GlobalNotificationSetting', 'type');
+  GlobalNotificationSetting.class.crowi = crowi;
+  GlobalNotificationSetting.schema.loadClass(GlobalNotificationSetting.class);
+  return createChildSchemas(GlobalNotificationSetting.schema, 'GlobalNotificationSetting', 'type');
 };

+ 16 - 1
lib/models/GlobalNotificationSetting/GlobalNotificationSettingClass.js → lib/models/GlobalNotificationSetting/index.js

@@ -1,3 +1,15 @@
+const mongoose = require('mongoose');
+
+/**
+ * parent schema for GlobalNotificationSetting model
+ */
+const globalNotificationSettingSchema = new mongoose.Schema({
+  isEnabled: { type: Boolean, required: true, default: true },
+  triggerPath: { type: String, required: true },
+  triggerEvents: { type: [String] },
+});
+
+
 /**
  * GlobalNotificationSetting Class
  * @class GlobalNotificationSetting
@@ -94,4 +106,7 @@ const generatePathsToMatch = (originalPath) => {
   });
 };
 
-module.exports = GlobalNotificationSetting;
+module.exports = {
+  class: GlobalNotificationSetting,
+  schema: globalNotificationSettingSchema,
+};

+ 1 - 1
lib/models/index.js

@@ -14,5 +14,5 @@ module.exports = {
   UpdatePost: require('./updatePost'),
   GlobalNotificationSetting: require('./GlobalNotificationSetting'),
   GlobalNotificationMailSetting: require('./GlobalNotificationSetting/GlobalNotificationMailSetting'),
-  GlobalNotificationSlackSetting: require('./GlobalNotificationSetting/GlobalNotificationSlackSetting'),
+  // GlobalNotificationSlackSetting: require('./GlobalNotificationSetting/GlobalNotificationSlackSetting'),
 };