Yuki Takei 4 лет назад
Родитель
Сommit
0972996fbc

+ 1 - 1
packages/app/src/server/models/update-post.ts

@@ -21,7 +21,7 @@ export interface UpdatePostModel extends Model<UpdatePostDocument> {
   normalizeChannelName(channel): any
   createPrefixesByPathPattern(pathPattern): any
   getRegExpByPattern(pattern): any
-  findSettingsByPath(path): UpdatePostDocument[]
+  findSettingsByPath(path): Promise<UpdatePostDocument[]>
   findAll(offset?: number): Promise<UpdatePostDocument[]>
   createUpdatePost(pathPattern: string, channel: string, creator: Types.ObjectId): Promise<UpdatePostDocument>
 }

+ 1 - 5
packages/app/src/server/service/user-notification/index.ts

@@ -1,6 +1,4 @@
-import mongoose from 'mongoose';
-
-import { UpdatePostDocument, UpdatePostModel } from '~/server/models/update-post';
+import UpdatePost from '~/server/models/update-post';
 import { toArrayFromCsv } from '~/utils/to-array-from-csv';
 
 
@@ -72,8 +70,6 @@ export class UserNotificationService {
   }
 
   private async putDefaultChannelIfEmpty(pagePath:string, slackChannels: (string|null)[]): Promise<void> {
-    const UpdatePost = mongoose.model<UpdatePostDocument, UpdatePostModel>('UpdatePost');
-
     const updatePosts = await UpdatePost.findSettingsByPath(pagePath);
     slackChannels.push(...(updatePosts).map(up => up.channel));