Files
gridpilot.gg/adapters/notifications/gateways/InAppNotificationGateway.ts
2025-12-15 18:49:10 +01:00

44 lines
1.3 KiB
TypeScript

/**
* Infrastructure Adapter: InAppNotificationAdapter
*
* Handles in-app notifications (stored in database, shown in UI).
* This is the primary/default notification channel.
*/
import type { Notification } from '../../domain/entities/Notification';
import type {
INotificationGateway,
NotificationDeliveryResult
} from '../../application/ports/INotificationGateway';
import type { NotificationChannel } from '../../domain/types/NotificationTypes';
export class InAppNotificationAdapter implements INotificationGateway {
private readonly channel: NotificationChannel = 'in_app';
/**
* For in_app, sending is essentially a no-op since the notification
* is already persisted by the use case. This just confirms delivery.
*/
async send(notification: Notification): Promise<NotificationDeliveryResult> {
// In-app notifications are stored directly in the repository
// This adapter just confirms the "delivery" was successful
return {
success: true,
channel: this.channel,
externalId: notification.id,
attemptedAt: new Date(),
};
}
supportsChannel(channel: NotificationChannel): boolean {
return channel === this.channel;
}
isConfigured(): boolean {
return true; // Always configured
}
getChannel(): NotificationChannel {
return this.channel;
}
}