Добавлены проверки и логирование
This commit is contained in:
parent
4f0355c09c
commit
c543acbbef
2 changed files with 12 additions and 2 deletions
|
|
@ -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<RedmineTypes.ExtendedIssue> {
|
||||
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[];
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue