From cff6427e33bd1676ab7927f7ac3d7ee50a9930f8 Mon Sep 17 00:00:00 2001
From: smart_ex <sergei.smart@gmail.com>
Date: Fri, 1 Jul 2022 12:58:35 +1000
Subject: [PATCH] add name prefix to notify

---
 src/services/notifier.service.ts | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/services/notifier.service.ts b/src/services/notifier.service.ts
index 4ae3ba4..5835ada 100644
--- a/src/services/notifier.service.ts
+++ b/src/services/notifier.service.ts
@@ -3,6 +3,7 @@ import { autoInjectable, container } from 'tsyringe';
 import { RedisStore } from '../modules/redis';
 import { ExtraReplyMessage } from 'telegraf/typings/telegram-types';
 import { netId } from '../config';
+import { ConfigService } from './config.service';
 
 export type Levels = keyof typeof AlertLevel;
 
@@ -39,11 +40,13 @@ export class NotifierService {
   private telegram: Telegram | MockTelegram;
   private readonly token: string;
   private readonly chatId: string;
+  prefix: string;
 
-  constructor(private store: RedisStore) {
+  constructor(private store: RedisStore, private config: ConfigService) {
     this.token = process.env.TELEGRAM_NOTIFIER_BOT_TOKEN;
     this.chatId = process.env.TELEGRAM_NOTIFIER_CHAT_ID;
     this.telegram = this.token ? new Telegram(this.token) : new MockTelegram();
+    this.prefix = this.config.host;
   }
 
   async processAlert(message: string) {
@@ -69,7 +72,7 @@ export class NotifierService {
   }
 
   send(message: string, level: Levels) {
-    const text = `${AlertLevel[level]} ${message}`;
+    const text = `${AlertLevel[level]} ${this.prefix}: ${message}`;
     return this.telegram.sendMessage(this.chatId, text, { parse_mode: 'HTML' });
   }