fix pub/sub

This commit is contained in:
smart_ex 2022-07-01 01:04:04 +10:00
parent 5aebdab767
commit 8c027dbfcf
3 changed files with 8 additions and 5 deletions

@ -91,7 +91,8 @@ export class HealthService {
}
async pushAlert(alert: Alert) {
await this.store.publisher.publish('user-notify', JSON.stringify(alert));
const channel = `${this.config.netId}/user-notify`;
await this.store.publisher.publish(channel, JSON.stringify(alert));
}
private async _checkBalance(value, currency: 'MAIN' | 'TORN') {

@ -2,6 +2,7 @@ import { Telegram } from 'telegraf';
import { autoInjectable, container } from 'tsyringe';
import { RedisStore } from '../modules/redis';
import { ExtraReplyMessage } from 'telegraf/typings/telegram-types';
import { netId } from '../config';
export type Levels = keyof typeof AlertLevel;
@ -60,7 +61,8 @@ export class NotifierService {
}
async subscribe() {
this.store.subscriber.subscribe('user-notify');
const channel = `${netId}/user-notify`;
this.store.subscriber.subscribe(channel);
this.store.subscriber.on('message', async (channel, message) => {
await this.processAlert(<string>message);
});