From c543acbbef486e03f22ab8df7682255fefebf75c Mon Sep 17 00:00:00 2001 From: Gnedov Pavel Date: Wed, 15 Feb 2023 10:50:11 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B8=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/issue-enhancers/tag-styled-enhancer.ts | 4 +++- .../adapters/status-change.adapter.service.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/event-emitter/src/issue-enhancers/tag-styled-enhancer.ts b/libs/event-emitter/src/issue-enhancers/tag-styled-enhancer.ts index 9b63b76..dbb8920 100644 --- a/libs/event-emitter/src/issue-enhancers/tag-styled-enhancer.ts +++ b/libs/event-emitter/src/issue-enhancers/tag-styled-enhancer.ts @@ -30,9 +30,10 @@ export namespace TagStyledEnhancerNs { export function CreateTagStyledEnhancerForConfig( cfg: ConfigWithTagsStyles, ): TagStyledEnhancer | null { - if (!cfg.tags) return null; + if (!cfg || !cfg.tags) return null; return new TagStyledEnhancer( (issue: RedmineTypes.ExtendedIssue) => { + if (!issue) return []; if ( typeof issue[cfg.tags.tagsKeyName] === 'object' && issue[cfg.tags.tagsKeyName].length > 0 @@ -64,6 +65,7 @@ export class TagStyledEnhancer implements IssueEnhancerInterface { async enhance( issue: RedmineTypes.ExtendedIssue, ): Promise { + if (!issue) return issue; const tags = this.tagsGetter(issue); this.logger.debug(`Found tags for issue_id = ${issue.id} - ${tags}`); const styles = [] as TagStyledEnhancerNs.StyledTag[]; diff --git a/src/notifications/adapters/status-change.adapter.service.ts b/src/notifications/adapters/status-change.adapter.service.ts index 9e9ecaa..b70271b 100644 --- a/src/notifications/adapters/status-change.adapter.service.ts +++ b/src/notifications/adapters/status-change.adapter.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import TelegramBot from 'node-telegram-bot-api'; import { Change } from 'src/models/change.model'; @@ -18,6 +18,7 @@ namespace StatusChangeAdapter { @Injectable() export class StatusChangeAdapterService { + private logger = new Logger(StatusChangeAdapterService.name); private periodValidityNotification: number; constructor( @@ -54,6 +55,7 @@ export class StatusChangeAdapterService { item.options = { parse_mode: 'HTML' }; return item; }); + this.logger.debug(`Change messages for sending to telegram - ${JSON.stringify(messages)}`); for (let i = 0; i < messages.length; i++) { const message = messages[i]; await this.telegramBotService.sendMessageByRedmineId( @@ -74,6 +76,12 @@ export class StatusChangeAdapterService { nowTimestamp - change.created_on_timestamp > this.periodValidityNotification ) { + this.logger.debug( + `Skipping sending due to the prescription ` + + `of the origin of the event - ` + + `issue_id = ${change.issue_id}, ` + + `messages = ${change.messages.map((m) => m.notification_message).filter((m) => !!m)}` + ); continue; } for (let j = 0; j < change.messages.length; j++) {