make FCM_SERVER_KEY optional in NotificationsService
This commit is contained in:
@@ -7,10 +7,14 @@ export class NotificationsService {
|
|||||||
private readonly fcmServerKey: string;
|
private readonly fcmServerKey: string;
|
||||||
|
|
||||||
constructor(private config: ConfigService) {
|
constructor(private config: ConfigService) {
|
||||||
this.fcmServerKey = this.config.getOrThrow<string>('FCM_SERVER_KEY');
|
this.fcmServerKey = this.config.get<string>('FCM_SERVER_KEY', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
async send(to: string, title: string, body: string, data?: Record<string, any>) {
|
async send(to: string, title: string, body: string, data?: Record<string, any>) {
|
||||||
|
if (!this.fcmServerKey) {
|
||||||
|
this.logger.warn('FCM_SERVER_KEY not set, skipping notification');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const message = {
|
const message = {
|
||||||
notification: { title, body },
|
notification: { title, body },
|
||||||
priority: 'high' as const,
|
priority: 'high' as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user