diff --git a/src/api/common/base.service.ts b/src/api/common/base.service.ts index 85ad6fb49..9a29974bb 100644 --- a/src/api/common/base.service.ts +++ b/src/api/common/base.service.ts @@ -129,6 +129,7 @@ export class BaseService { updateDto.updatedBy = req.user; updateDto.updated = new Date(); } + delete updateDto.id; return this.model.findByIdAndUpdate(id, updateDto).exec(); } @@ -138,6 +139,7 @@ export class BaseService { req: (Request & { user?: any }) | null, upsert: boolean = false, ): Promise { + delete updateDto.id; return this.findOneAndReplace(updateDto, { _id }, req, upsert); } @@ -151,6 +153,7 @@ export class BaseService { updateDto.updatedBy = req.user; updateDto.updated = new Date(); } + delete updateDto.id; const res = await this.model .findOneAndReplace(filter, updateDto, { upsert, diff --git a/src/observers/cron-tasks.service.ts b/src/observers/cron-tasks.service.ts index ec84665f7..3dcfd7f54 100644 --- a/src/observers/cron-tasks.service.ts +++ b/src/observers/cron-tasks.service.ts @@ -331,7 +331,7 @@ export class CronTasksService { items.push(item); } }); - feedparser.on('end', async function () { + feedparser.on('end', async () => { const itemKeyField = rssNtfctnConfigItem.value.rss.itemKeyField || 'guid'; const fieldsToCheckForUpdate = rssNtfctnConfigItem.value.rss @@ -400,6 +400,7 @@ export class CronTasksService { message, data: newOrUpdatedItem, httpHost: rssNtfctnConfigItem.value.httpHost, + asyncBroadcastPushNotification: true, }; const httpHost = this.appConfigService.get('internalHttpHost') || @@ -416,21 +417,21 @@ export class CronTasksService { }, }; try { - await fetch(url, options); + const res = await fetch(url, options); + if (res.status >= 400) + throw new HttpException(res.statusText, res.status); } catch (ex: any) { - this.logger.error(new Error(ex.message)); + this.logger.error(ex); } } }); if (!lastSavedRssData) { return; } - lastSavedRssData.items = items.concat(retainedOutdatedItems); - lastSavedRssData.lastPoll = ts; - await this.rssService.updateById( - lastSavedRssData.id, - lastSavedRssData, - ); + await this.rssService.updateById(lastSavedRssData.id, { + items: items.concat(retainedOutdatedItems), + lastPoll: ts, + }); }); const res = await fetch(rssNtfctnConfigItem.value.rss.url); if (res.status !== 200) { @@ -533,9 +534,11 @@ export class CronTasksService { }, }; try { - await fetch(url, options); + const res = await fetch(url, options); + if (res.status >= 400) + throw new HttpException(res.statusText, res.status); } catch (ex: any) { - this.logger.error(new Error(ex.message)); + this.logger.error(ex); } }, ),