feat: add directory opt-out sync and layout/xss seed data extensions
This commit is contained in:
@@ -80,6 +80,7 @@ const contactSchema = z.object({
|
||||
"Bitte eine gültige Postleitzahl angeben.",
|
||||
),
|
||||
city: z.string().trim().max(100).optional(),
|
||||
directoryOptIn: z.boolean().optional(),
|
||||
});
|
||||
|
||||
// Gibt die erste konkrete Field-Error-Message aus einem Zod-Fehler zurück,
|
||||
@@ -183,6 +184,20 @@ export async function updateMyContact(rawPayload: unknown) {
|
||||
}
|
||||
|
||||
try {
|
||||
const currentUser = await prisma.user.findUniqueOrThrow({
|
||||
where: { id: session.user.id },
|
||||
select: { directoryOptInAt: true },
|
||||
});
|
||||
|
||||
let newDirectoryOptInAt: Date | null = currentUser.directoryOptInAt;
|
||||
if (parsed.data.directoryOptIn) {
|
||||
if (!newDirectoryOptInAt) {
|
||||
newDirectoryOptInAt = new Date();
|
||||
}
|
||||
} else {
|
||||
newDirectoryOptInAt = null;
|
||||
}
|
||||
|
||||
await prisma.user.update({
|
||||
where: { id: session.user.id },
|
||||
data: {
|
||||
@@ -190,6 +205,7 @@ export async function updateMyContact(rawPayload: unknown) {
|
||||
street: parsed.data.street || null,
|
||||
postalCode: parsed.data.postalCode || null,
|
||||
city: parsed.data.city || null,
|
||||
directoryOptInAt: newDirectoryOptInAt,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user