Auto-commit 2026-05-02 09:37

This commit is contained in:
2026-05-02 09:37:34 -04:00
parent b7600fa937
commit 35d004cde3
3809 changed files with 2315945 additions and 106 deletions

View File

@@ -15,23 +15,27 @@ export class PushService {
constructor(fcmConfig?: FCMConfig, apnsConfig?: APNsConfig) {
if (fcmConfig) {
if (!admin.apps.length && fcmConfig.keyPath) {
// Use named app instance for multi-tenant support
const appName = fcmConfig.keyPath
? `fcm_${fcmConfig.projectId}`
: 'fcm_default';
// Check if app with this name already exists
const existingApp = admin.app(appName);
if (!existingApp) {
this.fcm = admin.initializeApp({
credential: admin.credential.cert({
projectId: fcmConfig.projectId,
privateKey: fcmConfig.privateKey.replace(/\\n/g, '\n'),
clientEmail: fcmConfig.clientEmail,
}),
storageBucket: `${fcmConfig.projectId}.appspot.com`,
});
} else if (!admin.apps.length) {
this.fcm = admin.initializeApp({
credential: admin.credential.cert({
projectId: fcmConfig.projectId,
privateKey: fcmConfig.privateKey.replace(/\\n/g, '\n'),
clientEmail: fcmConfig.clientEmail,
...(fcmConfig.keyPath && {
storageBucket: `${fcmConfig.projectId}.appspot.com`,
}),
});
}, appName);
} else {
this.fcm = existingApp;
}
}
@@ -148,8 +152,9 @@ export class PushService {
return notification;
}
// APNs implementation would go here
// For now, we'll use FCM for iOS as well (FCM supports APNs)
// FCM supports sending to APNs tokens (iOS devices)
// This leverages FCM's unified push infrastructure for iOS
// APNs token format: device-specific token from iOS
if (this.fcm && recipient.apnsToken) {
const message: admin.messaging.Message = {
token: recipient.apnsToken,
@@ -246,12 +251,12 @@ export class PushService {
return !!this.fcm;
}
/**
* Shutdown FCM app
*/
async shutdown(): Promise<void> {
if (this.fcm) {
await this.fcm.terminate();
/**
* Shutdown FCM app
*/
async shutdown(): Promise<void> {
if (this.fcm) {
await this.fcm.delete();
}
}
}
}