courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 12:22:40 +02:00
parent cf0f724323
commit 4bfb348082

View File

@ -18,6 +18,7 @@ import {
invalidateEmailContentCache invalidateEmailContentCache
} from '@/lib/redis'; } from '@/lib/redis';
import { EmailCredentials, EmailMessage, EmailAddress, EmailAttachment } from '@/lib/types'; import { EmailCredentials, EmailMessage, EmailAddress, EmailAttachment } from '@/lib/types';
import { PrismaClient } from '@prisma/client';
// Types specific to this service // Types specific to this service
export interface EmailListResult { export interface EmailListResult {
@ -150,7 +151,7 @@ export async function getImapConnection(userId: string): Promise<ImapFlow> {
* Get user's email credentials from database * Get user's email credentials from database
*/ */
export async function getUserEmailCredentials(userId: string): Promise<EmailCredentials | null> { export async function getUserEmailCredentials(userId: string): Promise<EmailCredentials | null> {
const credentials = await prisma.mailCredentials.findUnique({ const credentials = await prisma.mailCredentials.findFirst({
where: { userId }, where: { userId },
select: { select: {
id: true, id: true,
@ -169,14 +170,14 @@ export async function getUserEmailCredentials(userId: string): Promise<EmailCred
updatedAt: true updatedAt: true
} }
}); });
if (!credentials) { if (!credentials) {
return null; return null;
} }
// Cache the credentials // Cache the credentials
await cacheEmailCredentials(userId, credentials); await cacheEmailCredentials(userId, credentials);
return credentials; return credentials;
} }