mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 05:18:11 +00:00
refactor( iam ): replace userId FK with iamUserId on UserPreferences, Device, FraudAlert
This commit is contained in:
@@ -166,20 +166,21 @@ export class NotificationsService {
|
||||
|
||||
private async getUserPreferredChannels(recipient: string): Promise<NotificationChannelType[]> {
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: {
|
||||
OR: [{ id: recipient }, { email: recipient }, { phone: recipient }],
|
||||
},
|
||||
include: { preferences: true },
|
||||
where: { OR: [{ id: recipient }, { email: recipient }, { phone: recipient }] },
|
||||
include: { passenger: { select: { iamUserId: true } } },
|
||||
});
|
||||
|
||||
if (!user?.preferences) {
|
||||
const iamUserId = user?.passenger?.iamUserId ?? recipient;
|
||||
const preferences = await this.prisma.userPreferences.findUnique({ where: { iamUserId } });
|
||||
|
||||
if (!preferences) {
|
||||
return ['IN_APP', 'EMAIL'];
|
||||
}
|
||||
|
||||
const channels: NotificationChannelType[] = ['IN_APP'];
|
||||
if (user.preferences.emailEnabled) channels.push('EMAIL');
|
||||
if (user.preferences.smsEnabled) channels.push('SMS');
|
||||
if (user.preferences.pushEnabled) channels.push('PUSH');
|
||||
if (preferences.emailEnabled) channels.push('EMAIL');
|
||||
if (preferences.smsEnabled) channels.push('SMS');
|
||||
if (preferences.pushEnabled) channels.push('PUSH');
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user