Terminplaner TP2 C4a: Nachbesserung 1
Die Wahl des Live-Hosts steht jetzt nur noch in liveHost() (kontext.js); websiteUrl() und der Betriebsvorschlag des Fragebogens (routes/termine.js) nutzen dieselbe Funktion. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
250fc0c4df
commit
42a3befc5f
3 files changed
+43
-13
No files matched your search
@@ -2,7 +2,6 @@ import { Router } from 'express'
|
||||
import { config } from '../config.js'
|
||||
import { getSessionCustomerId, requireSession } from '../middleware/session.js'
|
||||
import { aboMemo } from '../services/aboStatus.js'
|
||||
import { analyseHosts } from '../services/analyse.js'
|
||||
import { getDocument } from '../services/appwriteAdmin.js'
|
||||
import { analysePrivacyData } from '../services/analysePrivacy.js'
|
||||
import { featureConfig } from '../services/featureRegistry.js'
|
||||
@@ -15,7 +14,7 @@ import { EXPORT_SEITE, exportSeite, hole, imZeitraum, zaehleAnfragen, zaehleKuen
|
||||
import { fehlendePflichtangaben, neuerFeedToken, normalisiereEinstellung } from '../services/termine/einstellungen.js'
|
||||
import { loeschTag, loeschzeit } from '../services/termine/frist.js'
|
||||
import { BRANCHEN, bestellpruefung, bestellungAnsicht, leerFragebogen } from '../services/termine/fragebogen.js'
|
||||
import { kontextFuerPortal, kontextPerFeature, speichereEinstellung } from '../services/termine/kontext.js'
|
||||
import { kontextFuerPortal, kontextPerFeature, liveHost, speichereEinstellung } from '../services/termine/kontext.js'
|
||||
import { zustellFehler } from '../services/termine/outbox.js'
|
||||
import { termineFuerKunde } from '../services/termine/schalter.js'
|
||||
import { belegungAus, freieZeiten } from '../services/termine/slots.js'
|
||||
@@ -305,11 +304,9 @@ async function betriebAusKonto(customerId) {
|
||||
return { name: daten.company, adresse: daten.address, email: daten.email, telefon: typeof kunde?.phone === 'string' ? kunde.phone : '' }
|
||||
}
|
||||
|
||||
/** Adresse der Live-Website des Projekts (nur aus liveDomain, nie die Vorschau-Adresse <subdomain>.project.webklar.com), sonst ''. */
|
||||
/** Adresse der Live-Website des Projekts (liveHost: nur aus liveDomain, nie die Vorschau-Adresse <subdomain>.project.webklar.com), sonst ''. */
|
||||
function liveWebsite(project) {
|
||||
if (!project?.liveDomain) return ''
|
||||
const vorschau = project.subdomain ? `${String(project.subdomain).trim().toLowerCase()}.project.webklar.com` : null
|
||||
const host = analyseHosts(project).find((h) => h !== vorschau)
|
||||
const host = liveHost(project)
|
||||
return host ? `https://${host}` : ''
|
||||
}
|
||||
|
||||
|
||||
@@ -301,10 +301,26 @@ export async function speichereFragebogen(feature, aendere, { by = '', now = new
|
||||
})
|
||||
}
|
||||
|
||||
/** Vorschau-Host des Projekts (<subdomain>.project.webklar.com, klein) oder null; gleiche Schreibweise wie in analyseHosts. */
|
||||
function vorschauHost(project) {
|
||||
return project.subdomain ? `${String(project.subdomain).trim().toLowerCase()}.project.webklar.com` : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Host der echten (Live-)Website eines Projekts: nur wenn project.liveDomain gesetzt ist, der erste gueltige Host aus
|
||||
* analyseHosts(project), der nicht die Vorschau-Adresse <subdomain>.project.webklar.com ist; sonst undefined.
|
||||
* Einzige Quelle fuer websiteUrl() und den Betriebsvorschlag des Fragebogens (routes/termine.js).
|
||||
*/
|
||||
export function liveHost(project) {
|
||||
if (!project?.liveDomain) return undefined
|
||||
const vorschau = vorschauHost(project)
|
||||
return analyseHosts(project).find((host) => host !== vorschau)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adresse der Website des Betriebs (Link auf Gaesteseiten und im Mailfuss), immer die echte Seite statt der Vorschau:
|
||||
* betrieb.websiteUrl; sonst https:// + Live-Domain des Projekts (wenn project.liveDomain einen gueltigen Host ergibt);
|
||||
* sonst https:// + <subdomain>.project.webklar.com; sonst die Portal-Adresse (config.publicBaseUrl).
|
||||
* betrieb.websiteUrl; sonst https:// + Live-Domain des Projekts (liveHost); sonst https:// + <subdomain>.project.webklar.com;
|
||||
* sonst die Portal-Adresse (config.publicBaseUrl).
|
||||
*/
|
||||
export function websiteUrl(ctx) {
|
||||
const eigene = ctx?.einstellung?.betrieb?.websiteUrl
|
||||
@@ -312,10 +328,8 @@ export function websiteUrl(ctx) {
|
||||
const project = ctx?.project
|
||||
if (project) {
|
||||
// analyseHosts: [<subdomain>.project.webklar.com, Live-Domain], ungueltige und doppelte Hosts fehlen
|
||||
const hosts = analyseHosts(project)
|
||||
const vorschau = project.subdomain ? `${String(project.subdomain).trim().toLowerCase()}.project.webklar.com` : null
|
||||
const live = project.liveDomain ? hosts.find((host) => host !== vorschau) : undefined
|
||||
const host = live ?? hosts.find((h) => h === vorschau)
|
||||
const vorschau = vorschauHost(project)
|
||||
const host = liveHost(project) ?? analyseHosts(project).find((h) => h === vorschau)
|
||||
if (host) return `https://${host}`
|
||||
}
|
||||
return config.publicBaseUrl
|
||||
|
||||
Reference in new issue
Block a user