Files
Webklar-Kundenbereich/server/services/analyseConsent.js
T

16 lines
903 B
JavaScript

// Website-Analyse: Einwilligungs-Historie je Projekt (Collection analyseConsents).
// Nur anfuegen und lesen: es gibt bewusst keine Aenderungs- und Loeschfunktion.
import { config } from '../config.js'
import { createDocument, listDocuments, Query } from './appwriteAdmin.js'
/** @param {{customerId,projectId,siteKey,event,avvVersion,via,acceptedAt,acceptedBy,textformDate,textformChannel}} entry */
export async function recordConsent(entry) {
return createDocument(config.collections.analyseConsents, entry)
}
/** Alle Eintraege eines Projekts, aelteste zuerst. */
export async function listConsents(projectId) {
const docs = await listDocuments(config.collections.analyseConsents, [Query.equal('projectId', projectId), Query.limit(500)])
return [...docs].sort((a, b) => String(a.acceptedAt).localeCompare(String(b.acceptedAt)) || String(a.$createdAt).localeCompare(String(b.$createdAt)))
}