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++) {