Schalter TERMINE_ENABLED (off|pilot|on) mit TERMINE_PILOT_EMAILS, config.termine und die vier Collection-IDs, Schema der Termine-Collections als reine Daten (server/services/termine/schema.js), Setup-Skript scripts/termine-setup.mjs mit --check und schemaKeys() fuer den Appwrite-Nachbau der Tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { config } from '../../config.js'
|
|
|
|
/**
|
|
* Terminplaner-Schalter (Funktionsschluessel 'termine'): TERMINE_ENABLED = off (Vorgabe) | pilot | on.
|
|
* Liest config.termine bei jedem Aufruf. Bei off laufen keine Termine-Jobs und keine Termine-Abfragen.
|
|
*/
|
|
|
|
/** 'off' | 'pilot' | 'on'; alles andere (leer, unbekannt) gilt als off. */
|
|
export function termineModus() {
|
|
const mode = config.termine.mode
|
|
return mode === 'pilot' || mode === 'on' ? mode : 'off'
|
|
}
|
|
|
|
export function termineAus() {
|
|
return termineModus() === 'off'
|
|
}
|
|
|
|
/**
|
|
* Darf dieser Kunde den Terminplaner nutzen? pilot = nur Adressen aus TERMINE_PILOT_EMAILS ('*' = alle; eine leere
|
|
* Liste laesst niemanden durch); on = alle Kunden (TP1: pilot ohne E-Mail-Filter); off = niemand.
|
|
*/
|
|
export function termineFuerKunde(email) {
|
|
const modus = termineModus()
|
|
if (modus === 'off') return false
|
|
if (modus === 'on') return true
|
|
const erlaubt = config.termine.pilotEmails
|
|
if (erlaubt.includes('*')) return true
|
|
const adresse = String(email || '').trim().toLowerCase()
|
|
return adresse !== '' && erlaubt.includes(adresse)
|
|
}
|