mirror of
https://github.com/R0m1k3/PleinR.git
synced 2026-10-23 23:28:04 +02:00
URL publique du site réglable depuis le backoffice
Connecter un réseau social imposait de poser NEXT_PUBLIC_SITE_URL dans docker-compose et de redémarrer le conteneur. L'écran Réseaux sociaux porte désormais le champ, pré-rempli avec l'adresse par laquelle l'administrateur consulte la page. - Nouveau réglage `site_public_url` ; `siteUrl()` lit la base puis retombe sur les variables d'environnement, donc les déploiements actuels ne bougent pas. - `siteUrl()`, `redirectUri()`, `authorizeUrl()`, `promoLink()` et `buildPromoMessage()` deviennent asynchrones. - Seule l'origine est conservée : le schéma est ajouté s'il manque, un chemin est retiré, et une adresse invalide revient sur l'écran avec un message au lieu d'une page d'erreur brute. - `saveSiteSettings` saute cette clé : le formulaire Paramètres ne la contient pas et l'aurait écrasée à chaque enregistrement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QXNXRC4j5VLfKvpyyisrnb
This commit is contained in:
9 files changed
+146
-37
No files matched your search
+6
-6
@@ -39,20 +39,20 @@ export type PromoForSharing = {
|
||||
memberName: string | null;
|
||||
};
|
||||
|
||||
export function promoLink(promo: PromoForSharing): string | null {
|
||||
const base = siteUrl();
|
||||
export async function promoLink(promo: PromoForSharing): Promise<string | null> {
|
||||
const base = await siteUrl();
|
||||
if (!base) return null;
|
||||
return promo.memberId ? `${base}/adherents/${promo.memberId}` : `${base}/#promotions`;
|
||||
}
|
||||
|
||||
/** Texte du post, commun aux deux réseaux. */
|
||||
export function buildPromoMessage(promo: PromoForSharing): string {
|
||||
export async function buildPromoMessage(promo: PromoForSharing): Promise<string> {
|
||||
const lines: string[] = [];
|
||||
lines.push(promo.badge ? `${promo.badge} — ${promo.title}` : promo.title);
|
||||
if (promo.memberName) lines.push(`Chez ${promo.memberName}`);
|
||||
if (promo.text?.trim()) lines.push("", promo.text.trim());
|
||||
if (promo.validUntil?.trim()) lines.push("", promo.validUntil.trim());
|
||||
const link = promoLink(promo);
|
||||
const link = await promoLink(promo);
|
||||
if (link) lines.push("", link);
|
||||
lines.push("", "#PleinR #BassinDePompey #CommerceLocal");
|
||||
return lines.join("\n");
|
||||
@@ -133,7 +133,7 @@ async function publishToFacebook(promo: PromoForSharing, message: string): Promi
|
||||
} else {
|
||||
endpoint = `${base}/feed`;
|
||||
body.set("message", message);
|
||||
const link = promoLink(promo);
|
||||
const link = await promoLink(promo);
|
||||
if (link) body.set("link", link);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ export async function publishPromoToNetwork(
|
||||
network: SocialNetwork,
|
||||
promo: PromoForSharing
|
||||
): Promise<PublishResult> {
|
||||
const message = buildPromoMessage(promo);
|
||||
const message = await buildPromoMessage(promo);
|
||||
return network === "facebook"
|
||||
? publishToFacebook(promo, message)
|
||||
: publishToLinkedIn(promo, message);
|
||||
|
||||
Reference in new issue
Block a user