Просмотр исходного кода

undo removal of 'this' in static for mongoose models

Futa Arai 5 месяцев назад
Родитель
Сommit
ff88837c15

+ 8 - 4
apps/app/src/server/models/GlobalNotificationSetting/index.js

@@ -61,7 +61,8 @@ class GlobalNotificationSetting {
    * @param {string} id
    * @param {string} id
    */
    */
   static async enable(id) {
   static async enable(id) {
-    const setting = await GlobalNotificationSetting.findOne({ _id: id });
+    // biome-ignore lint/complexity/noThisInStatic: 'this' refers to the mongoose model here, not the class defined in this file
+    const setting = await this.findOne({ _id: id });
 
 
     setting.isEnabled = true;
     setting.isEnabled = true;
     setting.save();
     setting.save();
@@ -74,7 +75,8 @@ class GlobalNotificationSetting {
    * @param {string} id
    * @param {string} id
    */
    */
   static async disable(id) {
   static async disable(id) {
-    const setting = await GlobalNotificationSetting.findOne({ _id: id });
+    // biome-ignore lint/complexity/noThisInStatic: 'this' refers to the mongoose model here, not the class defined in this file
+    const setting = await this.findOne({ _id: id });
 
 
     setting.isEnabled = false;
     setting.isEnabled = false;
     setting.save();
     setting.save();
@@ -86,7 +88,8 @@ class GlobalNotificationSetting {
    * find all notification settings
    * find all notification settings
    */
    */
   static async findAll() {
   static async findAll() {
-    const settings = await GlobalNotificationSetting.find().sort({
+    // biome-ignore lint/complexity/noThisInStatic: 'this' refers to the mongoose model here, not the class defined in this file
+    const settings = await this.find().sort({
       triggerPath: 1,
       triggerPath: 1,
     });
     });
 
 
@@ -101,7 +104,8 @@ class GlobalNotificationSetting {
   static async findSettingByPathAndEvent(event, path, type) {
   static async findSettingByPathAndEvent(event, path, type) {
     const pathsToMatch = generatePathsToMatch(path);
     const pathsToMatch = generatePathsToMatch(path);
 
 
-    const settings = await GlobalNotificationSetting.find({
+    // biome-ignore lint/complexity/noThisInStatic: 'this' refers to the mongoose model here, not the class defined in this file
+    const settings = await this.find({
       triggerPath: { $in: pathsToMatch },
       triggerPath: { $in: pathsToMatch },
       triggerEvents: event,
       triggerEvents: event,
       __t: type,
       __t: type,

+ 2 - 2
apps/app/src/server/models/slack-app-integration.js

@@ -54,8 +54,8 @@ class SlackAppIntegration {
       );
       );
       tokenGtoP = generateTokens[0];
       tokenGtoP = generateTokens[0];
       tokenPtoG = generateTokens[1];
       tokenPtoG = generateTokens[1];
-      // eslint-disable-next-line no-await-in-loop
-      duplicateTokens = await SlackAppIntegration.findOne({
+      // biome-ignore lint/complexity/noThisInStatic: 'this' refers to the mongoose model here, not the class defined in this file
+      duplicateTokens = await this.findOne({
         $or: [{ tokenGtoP }, { tokenPtoG }],
         $or: [{ tokenGtoP }, { tokenPtoG }],
       });
       });
     } while (duplicateTokens != null);
     } while (duplicateTokens != null);