Skip to content

Commit 0f381e8

Browse files
committed
feat: add panelVersion to ServiceEvent and update event handling
- Introduced `panelVersion` property in `IServiceEvent` interface. - Updated `onPanelStarted` method to utilize `panelVersion` from the event data instead of the package version. - Adjusted `onApplicationBootstrap` to emit `panelVersion` when the panel starts.
1 parent 99155a1 commit 0f381e8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/integration-modules/notifications/interfaces/service.event.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface IServiceEvent {
88
description?: string;
99
password?: string;
1010
};
11+
panelVersion?: string;
1112
}
1213

1314
export class ServiceEvent {

src/integration-modules/notifications/telegram-bot/events/service/service.events.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { InjectBot } from '@kastov/grammy-nestjs';
2-
import { readPackageJSON } from 'pkg-types';
32
import { Context } from 'grammy';
43
import { Bot } from 'grammy';
54

@@ -28,13 +27,11 @@ export class ServiceEvents {
2827
}
2928

3029
@OnEvent(EVENTS.SERVICE.PANEL_STARTED)
31-
async onPanelStarted(): Promise<void> {
32-
const pkg = await readPackageJSON();
33-
30+
async onPanelStarted(event: ServiceEvent): Promise<void> {
3431
const msg = `
3532
🌊 <b>#panel_started</b>
3633
➖➖➖➖➖➖➖➖➖
37-
✅ Remnawave v${pkg.version} is up and running.
34+
✅ Remnawave v${event.data.panelVersion} is up and running.
3835
3936
🦋 Join community: @remnawave
4037
📚 Documentation: https://docs.rw

src/modules/remnawave-service/remnawave-service.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { readPackageJSON } from 'pkg-types';
2+
13
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
24
import { EventEmitter2 } from '@nestjs/event-emitter';
35

@@ -10,9 +12,13 @@ export class RemnawaveServiceService implements OnApplicationBootstrap {
1012
constructor(private readonly eventEmitter: EventEmitter2) {}
1113

1214
public async onApplicationBootstrap(): Promise<void> {
15+
const pkg = await readPackageJSON();
16+
1317
this.eventEmitter.emit(
1418
EVENTS.SERVICE.PANEL_STARTED,
15-
new ServiceEvent(EVENTS.SERVICE.PANEL_STARTED, {}),
19+
new ServiceEvent(EVENTS.SERVICE.PANEL_STARTED, {
20+
panelVersion: pkg.version,
21+
}),
1622
);
1723
}
1824
}

0 commit comments

Comments
 (0)