feat(push): log push provider config status on startup

Print ✓/✗ for each platform (FCM/HMS/MI/OPPO/VIVO) so missing credentials
are immediately visible in container logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-10 04:48:26 -07:00
parent 155133a2d6
commit bc48be1c95
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { DevicePushTokenRepository } from '../../infrastructure/repositories/device-push-token.repository';
import { DevicePushToken } from '../../domain/entities/device-push-token.entity';
import { PushProvider, PushMessage } from './push-providers/push-provider.interface';
@ -33,7 +33,7 @@ export interface NotificationForPush {
* Invalid tokens returned by providers are automatically deleted from DB.
*/
@Injectable()
export class OfflinePushService {
export class OfflinePushService implements OnModuleInit {
private readonly logger = new Logger(OfflinePushService.name);
private readonly providers: Map<string, PushProvider>;
@ -54,6 +54,16 @@ export class OfflinePushService {
]);
}
onModuleInit(): void {
for (const [platform, provider] of this.providers) {
if (provider.isConfigured()) {
this.logger.log(`[Push] ${platform} ✓ configured`);
} else {
this.logger.warn(`[Push] ${platform} ✗ NOT configured (credentials missing)`);
}
}
}
sendForNotification(notification: NotificationForPush): void {
this._send(notification).catch((err) => {
this.logger.error(`Offline push failed for ${notification.id}: ${err.message}`);