mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 19:51:46 +00:00
- Updated TransactionNotificationListener to differentiate between internal transfers and external top-ups for child accounts. - Added new notification scopes and messages for internal transfers from parent to child. - Improved balance retrieval logic to ensure accurate account balances are displayed in notifications. - Enhanced localization support by adding relevant keys for internal transfer notifications in both English and Arabic.
67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
export enum NotificationScope {
|
|
// Existing scopes
|
|
USER_REGISTERED = 'USER_REGISTERED',
|
|
TASK_COMPLETED = 'TASK_COMPLETED',
|
|
GIFT_RECEIVED = 'GIFT_RECEIVED',
|
|
OTP = 'OTP',
|
|
USER_INVITED = 'USER_INVITED',
|
|
|
|
// Transaction notifications - Top-up (external funds)
|
|
CHILD_TOP_UP = 'CHILD_TOP_UP',
|
|
PARENT_TOP_UP_CONFIRMATION = 'PARENT_TOP_UP_CONFIRMATION',
|
|
|
|
// Transaction notifications - Internal Transfer (parent to child)
|
|
CHILD_INTERNAL_TRANSFER = 'CHILD_INTERNAL_TRANSFER',
|
|
PARENT_INTERNAL_TRANSFER = 'PARENT_INTERNAL_TRANSFER',
|
|
|
|
// Transaction notifications - Spending
|
|
CHILD_SPENDING = 'CHILD_SPENDING',
|
|
PARENT_SPENDING_ALERT = 'PARENT_SPENDING_ALERT',
|
|
|
|
// Money Request notifications
|
|
MONEY_REQUEST_CREATED = 'MONEY_REQUEST_CREATED',
|
|
MONEY_REQUEST_APPROVED = 'MONEY_REQUEST_APPROVED',
|
|
MONEY_REQUEST_DECLINED = 'MONEY_REQUEST_DECLINED',
|
|
|
|
// KYC Update notifications
|
|
KYC_APPROVED = 'KYC_APPROVED',
|
|
KYC_REJECTED = 'KYC_REJECTED',
|
|
|
|
// Card Status notifications
|
|
CARD_CREATED = 'CARD_CREATED',
|
|
CARD_BLOCKED = 'CARD_BLOCKED',
|
|
CARD_REISSUED = 'CARD_REISSUED',
|
|
|
|
// Profile Update notifications
|
|
PROFILE_UPDATED = 'PROFILE_UPDATED',
|
|
|
|
// System Alert notifications
|
|
MAINTENANCE_ALERT = 'MAINTENANCE_ALERT',
|
|
TRANSACTION_FAILED = 'TRANSACTION_FAILED',
|
|
SUSPICIOUS_LOGIN = 'SUSPICIOUS_LOGIN',
|
|
}
|
|
|
|
/**
|
|
* Critical notification scopes that require guaranteed delivery
|
|
* These will use RabbitMQ/Kafka instead of Redis PubSub when configured
|
|
*
|
|
* Add scopes here when you need guaranteed delivery for specific notification types
|
|
* Examples:
|
|
* - ACCOUNT_LOCKED
|
|
* - SUSPICIOUS_ACTIVITY
|
|
* - LARGE_TRANSACTION_ALERT
|
|
* - PAYMENT_FAILED
|
|
*/
|
|
export const CRITICAL_NOTIFICATION_SCOPES = new Set<NotificationScope>([
|
|
// Add critical scopes here as needed
|
|
// Example: NotificationScope.ACCOUNT_LOCKED,
|
|
]);
|
|
|
|
/**
|
|
* Check if a notification scope requires guaranteed delivery
|
|
* @param scope - Notification scope to check
|
|
* @returns true if the scope requires guaranteed delivery
|
|
*/
|
|
export function requiresGuaranteedDelivery(scope: NotificationScope): boolean {
|
|
return CRITICAL_NOTIFICATION_SCOPES.has(scope);
|
|
} |