Rechtstexte: Dokument-Registry und Fassungskonstante des Terminplaners
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
938b7099dd
commit
b20d0464c4
6 files changed
+414
-53
No files matched your search
+37
-2
@@ -145,6 +145,25 @@ const ustHinweis = 'ohne Umsatzsteuer gemäß § 19 UStG'
|
||||
|
||||
const ticketProjektName = (project) => project?.projectName || project?.subdomain || ''
|
||||
|
||||
/**
|
||||
* Rechtsunterlage des Terminplaners mit Fassung und Adresse aus config.termine.avvVersion (bei jedem Zugriff gelesen).
|
||||
* Tests duerfen sie ueberschreiben (Zuweisung); wird der aktuelle Standardwert zurueckgeschrieben (Wiederherstellen nach
|
||||
* dem Test) oder null/undefined zugewiesen, gilt wieder der Standard und die Unterlage folgt der Konstante.
|
||||
*/
|
||||
function termineRechtsunterlage(slug) {
|
||||
let ueberschrieben = null
|
||||
const standard = () => ({ version: config.termine.avvVersion, url: `/rechtliches/${slug}-${config.termine.avvVersion}.html` })
|
||||
return {
|
||||
get: () => ueberschrieben ?? standard(),
|
||||
set(wert) {
|
||||
const std = standard()
|
||||
ueberschrieben = wert == null || (wert.version === std.version && wert.url === std.url) ? null : wert
|
||||
},
|
||||
}
|
||||
}
|
||||
const termineLb = termineRechtsunterlage('leistungsbeschreibung-terminplaner')
|
||||
const termineAvv = termineRechtsunterlage('avv-terminplaner')
|
||||
|
||||
/**
|
||||
* Register der kaufbaren Funktionen (News-Pinnwand, Terminplaner): Preis, Zustimmungen, Rechtsunterlagen,
|
||||
* Ticket- und Mail-Texte je Funktion; reine Daten, config.js importiert keine Dienste. Die Helfer (featureConfig,
|
||||
@@ -234,8 +253,20 @@ const features = {
|
||||
},
|
||||
],
|
||||
},
|
||||
leistungsbeschreibung: { version: 'ENTWURF', url: '' },
|
||||
avv: { version: 'ENTWURF', url: '' },
|
||||
// Fassung und Adresse folgen config.termine.avvVersion bei jedem Zugriff (Slugs wie in services/legalDocs.js; config.js
|
||||
// importiert keine Dienste, test/legalDocs.test.js gleicht beide ab)
|
||||
get leistungsbeschreibung() {
|
||||
return termineLb.get()
|
||||
},
|
||||
set leistungsbeschreibung(wert) {
|
||||
termineLb.set(wert)
|
||||
},
|
||||
get avv() {
|
||||
return termineAvv.get()
|
||||
},
|
||||
set avv(wert) {
|
||||
termineAvv.set(wert)
|
||||
},
|
||||
widerruf: null,
|
||||
returnHash: 'termine',
|
||||
returnProjekt: true,
|
||||
@@ -527,6 +558,10 @@ export const config = {
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
// Fassung der Terminplaner-Bestellunterlagen (Leistungsbeschreibung, AVV, Widerrufsbelehrung, Bestelltexte, News-
|
||||
// Zustimmung): Berliner Kalendertag des Fassungs-Commits (JJJJ-MM-TT). Eine ausgelieferte Fassung wird nie
|
||||
// ueberschrieben: nach Uebergabe an die Kanzlei oder Livegang heisst jede Textaenderung neues Datum und neue Dateien.
|
||||
avvVersion: '2026-10-05',
|
||||
holdMinutes: 30,
|
||||
zelleMin: 5,
|
||||
mailsProStunde: 200,
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ import newsRoutes from './routes/news.js'
|
||||
import publicNewsRoutes from './routes/publicNews.js'
|
||||
import publicTermineRoutes from './routes/publicTermine.js'
|
||||
import adminAnalyseRoutes from './routes/admin/analyse.js'
|
||||
import { analyseLegalRouter } from './services/analyseLegal.js'
|
||||
import { legalRouter } from './services/legalDocs.js'
|
||||
import adminFinanzenRoutes from './routes/admin/finanzen.js'
|
||||
import teamRoutes from './routes/team/index.js'
|
||||
import legacyAdminRedirect from './routes/legacyAdminRedirect.js'
|
||||
@@ -110,8 +110,8 @@ app.use('/embed/', (_req, res, next) => {
|
||||
res.set('Access-Control-Allow-Origin', '*')
|
||||
next()
|
||||
})
|
||||
// Adressen ohne Fassung: aktuelle geprüfte Fassung der Analyse-Rechtstexte (vor express.static)
|
||||
app.use('/rechtliches', analyseLegalRouter())
|
||||
// Adressen ohne Fassung: aktuelle Fassung der Rechtstexte (Analyse und Terminplaner; vor express.static)
|
||||
app.use('/rechtliches', legalRouter())
|
||||
// Abgeschaltetes Admin-Panel und Rechnungsanalyse: Links aus alten Team-Mails ins Ticketsystem
|
||||
app.use('/admin.html', legacyAdminRedirect.admin)
|
||||
app.use('/kalkulation.html', legacyAdminRedirect.kalkulation)
|
||||
|
||||
@@ -1,54 +1,13 @@
|
||||
// Veroeffentlichte Rechtstexte der Website-Analyse (je Fassung feste Dateien unter public/rechtliches/)
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { join } from 'node:path'
|
||||
import { Router } from 'express'
|
||||
import { config } from '../config.js'
|
||||
// Veroeffentlichte Rechtstexte der Website-Analyse (je Fassung feste Dateien unter public/rechtliches/):
|
||||
// duenner Wrapper um die Dokument-Registry legalDocs.js (Satz 'analyse')
|
||||
import { legalPaths as registryPaths, legalPdfAttachments as registryAttachments, legalPdfFiles as registryFiles, legalRouter } from './legalDocs.js'
|
||||
|
||||
const publicDir = fileURLToPath(new URL('../../public/', import.meta.url))
|
||||
const VERSION_RE = /^\d{4}-\d{2}-\d{2}$/
|
||||
export const legalPaths = (version) => registryPaths('analyse', version)
|
||||
|
||||
function checkVersion(version) {
|
||||
if (!VERSION_RE.test(String(version))) throw new Error('Analyse: ungültige Fassung')
|
||||
return String(version)
|
||||
}
|
||||
|
||||
export function legalPaths(version) {
|
||||
const v = checkVersion(version)
|
||||
return {
|
||||
avv: `/rechtliches/avv-website-analyse-${v}.html`,
|
||||
lb: `/rechtliches/leistungsbeschreibung-website-analyse-${v}.html`,
|
||||
}
|
||||
}
|
||||
|
||||
export function legalPdfFiles(version) {
|
||||
const v = checkVersion(version)
|
||||
return {
|
||||
avv: { filename: `AVV-Website-Analyse-${v}.pdf`, path: join(publicDir, 'rechtliches', `avv-website-analyse-${v}.pdf`) },
|
||||
lb: { filename: `Leistungsbeschreibung-Website-Analyse-${v}.pdf`, path: join(publicDir, 'rechtliches', `leistungsbeschreibung-website-analyse-${v}.pdf`) },
|
||||
}
|
||||
}
|
||||
export const legalPdfFiles = (version) => registryFiles('analyse', version)
|
||||
|
||||
/** Beide PDFs als Mail-Anhaenge; wirft, wenn eine Datei fehlt oder nicht lesbar ist. */
|
||||
export async function legalPdfAttachments(version) {
|
||||
const files = legalPdfFiles(version)
|
||||
return Promise.all(
|
||||
[files.avv, files.lb].map(async (f) => ({
|
||||
filename: f.filename,
|
||||
content: await readFile(f.path),
|
||||
contentType: 'application/pdf',
|
||||
}))
|
||||
)
|
||||
}
|
||||
export const legalPdfAttachments = (version) => registryAttachments('analyse', version)
|
||||
|
||||
/** Adressen ohne Fassung liefern immer die aktuelle geprüfte Fassung (config.analyse.avvVersion). */
|
||||
export function analyseLegalRouter() {
|
||||
const router = Router()
|
||||
const send = (key) => (_req, res, next) => {
|
||||
const file = join(publicDir, legalPaths(config.analyse.avvVersion)[key])
|
||||
res.sendFile(file, (err) => err && next(err.code === 'ENOENT' ? undefined : err))
|
||||
}
|
||||
router.get('/avv-website-analyse.html', send('avv'))
|
||||
router.get('/leistungsbeschreibung-website-analyse.html', send('lb'))
|
||||
return router
|
||||
}
|
||||
export const analyseLegalRouter = () => legalRouter({ saetze: ['analyse'] })
|
||||
@@ -0,0 +1,127 @@
|
||||
// Dokument-Registry der veroeffentlichten Rechtstexte (je Fassung feste Dateien unter public/rechtliches/):
|
||||
// Saetze 'analyse' (AVV, Leistungsbeschreibung der Website-Analyse) und 'termine' (Leistungsbeschreibung, AVV und
|
||||
// Widerrufsbelehrung mit Muster-Widerrufsformular des Terminplaners). analyseLegal.js ist ein duenner Wrapper darum.
|
||||
// Die Fassung ist der Berliner Kalendertag der Texte (JJJJ-MM-TT); eine ausgelieferte Fassung wird nie ueberschrieben.
|
||||
import { access, readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { join } from 'node:path'
|
||||
import { Router } from 'express'
|
||||
import { config } from '../config.js'
|
||||
|
||||
const publicDir = fileURLToPath(new URL('../../public/', import.meta.url))
|
||||
const VERSION_RE = /^\d{4}-\d{2}-\d{2}$/
|
||||
|
||||
/**
|
||||
* Dokumente je Satz in Anhangsreihenfolge: slug = Dateiname der HTML-Seite und des PDFs (<slug>-<Fassung>.html|pdf),
|
||||
* pdf = Dateiname des Mail-Anhangs (<pdf>-<Fassung>.pdf). config.js baut die Adressen des Terminplaners aus denselben
|
||||
* Slugs (config.js darf diese Datei nicht importieren); test/legalDocs.test.js gleicht beide ab.
|
||||
*/
|
||||
const SAETZE = {
|
||||
analyse: {
|
||||
avv: { slug: 'avv-website-analyse', pdf: 'AVV-Website-Analyse' },
|
||||
lb: { slug: 'leistungsbeschreibung-website-analyse', pdf: 'Leistungsbeschreibung-Website-Analyse' },
|
||||
},
|
||||
termine: {
|
||||
lb: { slug: 'leistungsbeschreibung-terminplaner', pdf: 'Leistungsbeschreibung-Terminplaner' },
|
||||
avv: { slug: 'avv-terminplaner', pdf: 'AVV-Terminplaner' },
|
||||
widerruf: { slug: 'widerrufsbelehrung-funktionen', pdf: 'Widerrufsbelehrung-Muster-Widerrufsformular' },
|
||||
},
|
||||
}
|
||||
|
||||
/** Satz, dessen Dokumente eine Funktion (Registerschluessel) mit der Bestellung bekommt; News hat keine. */
|
||||
const FUNKTION_SATZ = { news: null, termine: 'termine' }
|
||||
|
||||
/** Aktuelle Fassung je Satz, bei jedem Aufruf aus config gelesen (Tests aendern sie zur Laufzeit). */
|
||||
const aktuelleFassung = (satz) => (satz === 'analyse' ? config.analyse.avvVersion : config.termine.avvVersion)
|
||||
|
||||
function satzDokumente(satz) {
|
||||
if (typeof satz !== 'string' || !Object.hasOwn(SAETZE, satz)) throw new Error('Rechtstexte: unbekannter Satz')
|
||||
return SAETZE[satz]
|
||||
}
|
||||
|
||||
function pruefeFassung(version) {
|
||||
if (!VERSION_RE.test(String(version))) throw new Error('Rechtstexte: ungültige Fassung')
|
||||
return String(version)
|
||||
}
|
||||
|
||||
/** Adressen der versionierten HTML-Seiten: { [doc]: '/rechtliches/<slug>-<Fassung>.html' }. */
|
||||
export function legalPaths(satz, version) {
|
||||
const dokumente = satzDokumente(satz)
|
||||
const v = pruefeFassung(version)
|
||||
return Object.fromEntries(Object.entries(dokumente).map(([doc, d]) => [doc, `/rechtliches/${d.slug}-${v}.html`]))
|
||||
}
|
||||
|
||||
/** PDF je Dokument: { [doc]: { filename (Anhangsname), path (Datei unter public/rechtliches/) } }. */
|
||||
export function legalPdfFiles(satz, version) {
|
||||
const dokumente = satzDokumente(satz)
|
||||
const v = pruefeFassung(version)
|
||||
return Object.fromEntries(
|
||||
Object.entries(dokumente).map(([doc, d]) => [doc, { filename: `${d.pdf}-${v}.pdf`, path: join(publicDir, 'rechtliches', `${d.slug}-${v}.pdf`) }])
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* PDFs als Mail-Anhaenge in der Reihenfolge des Satzes (termine: lb, avv, widerruf; analyse: avv, lb); wirft, wenn eine
|
||||
* Datei fehlt oder nicht lesbar ist. ohne: Dokumente, die nicht angehaengt werden (sie muessen nicht vorhanden sein).
|
||||
*/
|
||||
export async function legalPdfAttachments(satz, version, { ohne = [] } = {}) {
|
||||
const dateien = legalPdfFiles(satz, version)
|
||||
for (const doc of ohne) {
|
||||
if (!Object.hasOwn(dateien, doc)) throw new Error('Rechtstexte: unbekanntes Dokument')
|
||||
}
|
||||
return Promise.all(
|
||||
Object.entries(dateien)
|
||||
.filter(([doc]) => !ohne.includes(doc))
|
||||
.map(async ([, f]) => ({ filename: f.filename, content: await readFile(f.path), contentType: 'application/pdf' }))
|
||||
)
|
||||
}
|
||||
|
||||
function funktionSatz(featureKey) {
|
||||
if (typeof featureKey !== 'string' || !Object.hasOwn(FUNKTION_SATZ, featureKey)) throw new Error('Rechtstexte: unbekannte Funktion')
|
||||
return FUNKTION_SATZ[featureKey]
|
||||
}
|
||||
|
||||
/**
|
||||
* Anhaenge der Bestellmail einer Funktion in der aktuellen Fassung: termine => Satz 'termine', news => []. Wirft bei
|
||||
* unbekannter Funktion und bei fehlender Datei (der Aufrufer entscheidet, was dann geschieht).
|
||||
*/
|
||||
export async function featureLegalAttachments(featureKey, opts) {
|
||||
const satz = funktionSatz(featureKey)
|
||||
return satz ? legalPdfAttachments(satz, aktuelleFassung(satz), opts) : []
|
||||
}
|
||||
|
||||
/**
|
||||
* true, wenn alle Rechtsdokumente der Funktion in der aktuellen Fassung vorliegen: HTML-Seiten (die die Bestellseite
|
||||
* verlinkt) und PDFs (die Mail anhaengt). Unbekannte Funktion und jeder Lesefehler: false (fail-closed).
|
||||
*/
|
||||
export async function featureLegalReady(featureKey) {
|
||||
try {
|
||||
const satz = funktionSatz(featureKey)
|
||||
if (!satz) return true
|
||||
const v = aktuelleFassung(satz)
|
||||
await Promise.all(Object.values(legalPaths(satz, v)).map((adresse) => access(join(publicDir, adresse))))
|
||||
await legalPdfAttachments(satz, v)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adressen ohne Fassung (/rechtliches/<slug>.html) liefern die Datei der aktuellen Fassung aus config. Nur fuer
|
||||
* Menschen und die WOMS-Karten: keine Mail und kein Zustimmungstext darf sie verlinken, denn sie aendern sich mit der
|
||||
* Fassung. Gehoert vor express.static; fehlt die Datei, geht die Anfrage weiter (404). saetze: welche Saetze bedient
|
||||
* werden, dir: Verzeichnis der Dateien (Standard public/rechtliches, Tests uebergeben ein eigenes).
|
||||
*/
|
||||
export function legalRouter({ saetze = Object.keys(SAETZE), dir = join(publicDir, 'rechtliches') } = {}) {
|
||||
const router = Router()
|
||||
for (const satz of saetze) {
|
||||
for (const d of Object.values(satzDokumente(satz))) {
|
||||
router.get(`/${d.slug}.html`, (_req, res, next) => {
|
||||
const datei = join(dir, `${d.slug}-${pruefeFassung(aktuelleFassung(satz))}.html`)
|
||||
res.sendFile(datei, (err) => err && next(err.code === 'ENOENT' ? undefined : err))
|
||||
})
|
||||
}
|
||||
}
|
||||
return router
|
||||
}
|
||||
Reference in new issue
Block a user