diff --git a/back/loaders/initTask.ts b/back/loaders/initTask.ts index c5158565..31d938aa 100644 --- a/back/loaders/initTask.ts +++ b/back/loaders/initTask.ts @@ -58,6 +58,6 @@ export default async () => { await subscriptionService.setSshConfig(); const subs = await subscriptionService.list(); for (const sub of subs) { - subscriptionService.handleTask(sub, !sub.is_disabled); + subscriptionService.handleTask(sub.get({ plain: true }), !sub.is_disabled); } }; diff --git a/back/services/subscription.ts b/back/services/subscription.ts index 6f917e54..69cc5fc2 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -3,6 +3,7 @@ import winston from 'winston'; import config from '../config'; import { Subscription, + SubscriptionInstance, SubscriptionModel, SubscriptionStatus, } from '../data/subscription'; @@ -44,7 +45,7 @@ export default class SubscriptionService { public async list( searchText?: string, ids?: string, - ): Promise { + ): Promise { let query = {}; const subIds = JSON.parse(ids || '[]'); if (searchText) { @@ -207,12 +208,12 @@ export default class SubscriptionService { public async create(payload: Subscription): Promise { const tab = new Subscription(payload); const doc = await this.insert(tab); - await this.handleTask(doc); + await this.handleTask(doc.get({ plain: true })); await this.setSshConfig(); return doc; } - public async insert(payload: Subscription): Promise { + public async insert(payload: Subscription): Promise { return await SubscriptionModel.create(payload, { returning: true }); } @@ -264,7 +265,7 @@ export default class SubscriptionService { public async remove(ids: number[], query: { force?: boolean }) { const docs = await SubscriptionModel.findAll({ where: { id: ids } }); for (const doc of docs) { - await this.handleTask(doc, false); + await this.handleTask(doc.get({ plain: true }), false); } await SubscriptionModel.destroy({ where: { id: ids } }); await this.setSshConfig(); @@ -341,7 +342,7 @@ export default class SubscriptionService { const docs = await SubscriptionModel.findAll({ where: { id: ids } }); await this.setSshConfig(); for (const doc of docs) { - await this.handleTask(doc, false); + await this.handleTask(doc.get({ plain: true }), false); } } @@ -350,7 +351,7 @@ export default class SubscriptionService { const docs = await SubscriptionModel.findAll({ where: { id: ids } }); await this.setSshConfig(); for (const doc of docs) { - await this.handleTask(doc); + await this.handleTask(doc.get({ plain: true })); } }