File: //proc/self/root/tmp/context_invites.mjs
import fs from 'node:fs';
const successFile = 'web/src/modules/photos/UploadSuccessPage.jsx';
let success = fs.readFileSync(successFile, 'utf8');
if (!success.includes('const getSuccessInviteContext =')) {
const helper = `
const getSuccessInviteContext = (entryPoint = '') => {
const entry = String(entryPoint || '').toLowerCase();
if (entry.includes('dating') || entry.includes('tinder') || entry.includes('bumble')) {
return {
key: 'dating',
label: 'Dating-Kontext',
nativeText: 'Kannst du kurz einschätzen, wie dieses Foto im Dating-Kontext wirkt?',
directText: 'Kannst du kurz einschätzen, wie dieses Foto im Dating-Kontext wirkt? Ich brauche ehrliche Stimmen für eine erste Tendenz:',
specificText: 'Wirkt dieses Dating-Foto offen, sympathisch und natürlich? Dein ehrlicher Eindruck hilft mir bei der Auswahl:',
groupText: 'Kurzer Dating-Foto-Check: Welches erste Signal sendet dieses Bild? Ich sammle 5 ehrliche Stimmen:',
directLabel: 'Dating-Direktcheck',
specificLabel: 'Sympathie prüfen',
groupLabel: 'Dating-Gruppe'
};
}
if (entry.includes('business') || entry.includes('linkedin') || entry.includes('bewerbung') || entry.includes('kompetent')) {
return {
key: 'business',
label: 'Business-Kontext',
nativeText: 'Kannst du kurz einschätzen, wie dieses Foto im Business-Kontext wirkt?',
directText: 'Kannst du kurz einschätzen, wie dieses Foto im Business-Kontext wirkt? Mir geht es um Kompetenz, Vertrauen und Nahbarkeit:',
specificText: 'Wirkt dieses Profilbild professionell und trotzdem zugänglich? Eine ehrliche Einschätzung hilft mir sehr:',
groupText: 'Kurzer Business-Foto-Check: Welchen beruflichen Ersteindruck macht dieses Bild? Ich sammle 5 Stimmen:',
directLabel: 'Business-Direktcheck',
specificLabel: 'LinkedIn-Wirkung',
groupLabel: 'Business-Gruppe'
};
}
if (entry.includes('social') || entry.includes('instagram') || entry.includes('facebook') || entry.includes('whatsapp') || entry.includes('selfie')) {
return {
key: 'social',
label: 'Social-Kontext',
nativeText: 'Kannst du kurz einschätzen, wie dieses Foto als Social-Profilbild wirkt?',
directText: 'Kannst du kurz einschätzen, wie dieses Foto als Social-Profilbild wirkt? Ich suche eine ehrliche erste Wirkung:',
specificText: 'Funktioniert dieses Foto auch klein als Profilbild und wirkt es sympathisch? Deine Stimme hilft:',
groupText: 'Kurzer Social-Profilbild-Check: Ich sammle 5 ehrliche Stimmen zur Wirkung dieses Fotos:',
directLabel: 'Social-Direktcheck',
specificLabel: 'Avatar-Wirkung',
groupLabel: 'Social-Gruppe'
};
}
return {
key: 'neutral',
label: 'Foto-Wirkung',
nativeText: 'Kannst du kurz einschätzen, wie dieses Foto wirkt?',
directText: 'Kannst du kurz einschätzen, wie dieses Foto wirkt? Ich sammle 5 ehrliche Stimmen für eine erste Tendenz:',
specificText: 'Wirkt dieses Foto sympathisch, klar und passend? Dein ehrlicher Eindruck hilft bei der Auswahl:',
groupText: 'Kurzer Foto-Check: Welche erste Wirkung hat dieses Bild? Ich sammle 5 ehrliche Stimmen:',
directLabel: 'Direkter Foto-Check',
specificLabel: 'Wirkung prüfen',
groupLabel: 'Gruppe oder Story'
};
};
`;
success = success.replace('\nconst InviteFirstPlan =', `${helper}\nconst InviteFirstPlan =`);
}
success = success.replace(
/const shareText = avgScore && Number\(stats\?\.votes \|\| 0\) >= 5[\s\S]*? const canNativeShare =/,
`const inviteContext = getSuccessInviteContext(entryPoint);\n const shareText = avgScore && Number(stats?.votes || 0) >= 5\n ? inviteContext.nativeText + ' Aktuell hat es ' + avgScore.toFixed(1) + ' Punkte.'\n : inviteContext.nativeText;\n const canNativeShare =`
);
success = success.replace(
/const sharePlaybook = buildPhotoInvitePlaybook\(\{[\s\S]*? \}\);/,
`const sharePlaybook = buildPhotoInvitePlaybook({\n photoId: numericId,\n avgScore,\n votes: Number(stats?.votes || 0),\n surface: 'upload_success',\n entryPoint\n });`
);
success = success.replace(
/const shareTemplates = \[[\s\S]*?\n \];\n\n const onCopy =/,
`const shareTemplates = [\n {\n id: inviteContext.key + '_direct',\n label: inviteContext.directLabel,\n text: inviteContext.directText + ' ' + copyShareUrl\n },\n {\n id: inviteContext.key + '_specific',\n label: inviteContext.specificLabel,\n text: inviteContext.specificText + ' ' + copyShareUrl\n },\n {\n id: inviteContext.key + '_group',\n label: inviteContext.groupLabel,\n text: inviteContext.groupText + ' ' + copyShareUrl\n }\n ];\n\n const onCopy =`
);
fs.writeFileSync(successFile, success, 'utf8');
const playbookFile = 'web/src/modules/photos/sharePlaybooks.js';
let playbook = fs.readFileSync(playbookFile, 'utf8');
if (!playbook.includes('const resolveInviteContext =')) {
const helper = `
const resolveInviteContext = (entryPoint = '') => {
const entry = String(entryPoint || '').toLowerCase();
if (entry.includes('dating') || entry.includes('tinder') || entry.includes('bumble')) {
return {
ask: 'Kannst du kurz einschätzen, wie dieses Foto im Dating-Kontext wirkt?',
direct: 'Kurzer Dating-Foto-Check?',
telegram: 'Kannst du mir kurz ehrliches Feedback zur Dating-Wirkung dieses Fotos geben?',
group: 'Brauche einen kurzen Dating-Foto-Check von ein paar Leuten:',
followup: 'Kannst du mein Dating-Foto bitte noch kurz bewerten?'
};
}
if (entry.includes('business') || entry.includes('linkedin') || entry.includes('bewerbung') || entry.includes('kompetent')) {
return {
ask: 'Kannst du kurz einschätzen, wie dieses Foto im Business-Kontext wirkt?',
direct: 'Kurzer Business-Foto-Check?',
telegram: 'Kannst du mir kurz ehrliches Feedback zur Business-Wirkung dieses Fotos geben?',
group: 'Brauche einen kurzen Business-Foto-Check von ein paar Leuten:',
followup: 'Kannst du mein Business-Profilbild bitte noch kurz bewerten?'
};
}
if (entry.includes('social') || entry.includes('instagram') || entry.includes('facebook') || entry.includes('whatsapp') || entry.includes('selfie')) {
return {
ask: 'Kannst du kurz einschätzen, wie dieses Foto als Social-Profilbild wirkt?',
direct: 'Kurzer Social-Profilbild-Check?',
telegram: 'Kannst du mir kurz ehrliches Feedback zur Social-Wirkung dieses Fotos geben?',
group: 'Brauche einen kurzen Social-Profilbild-Check von ein paar Leuten:',
followup: 'Kannst du mein Social-Profilbild bitte noch kurz bewerten?'
};
}
return {
ask: 'Kannst du kurz einschätzen, wie dieses Foto wirkt?',
direct: 'Kurzer ehrlicher Foto-Check?',
telegram: 'Kannst du mir kurz ehrliches Feedback zur Wirkung dieses Fotos geben?',
group: 'Brauche einen kurzen Profilbild-Check von ein paar Leuten:',
followup: 'Kannst du dieses Foto bitte noch kurz bewerten?'
};
};
`;
playbook = playbook.replace('\nconst remainingVotesText =', `${helper}\nconst remainingVotesText =`);
}
playbook = playbook.replace(
/export const buildPhotoInvitePlaybook = \(\{ photoId, avgScore, votes, surface = 'upload_success' \}\) => \{/,
`export const buildPhotoInvitePlaybook = ({ photoId, avgScore, votes, surface = 'upload_success', entryPoint = '' }) => {`
);
playbook = playbook.replace(
/const followupText = `Kurzer Reminder: \$\{remainingVotesText\(votes\)\} Kannst du mein Profilbild bitte noch kurz bewerten\?`;/,
`const context = resolveInviteContext(entryPoint);\n const followupText = 'Kurzer Reminder: ' + remainingVotesText(votes) + ' ' + context.followup;`
);
playbook = playbook.replace(
/href: buildWhatsappHref\(`Kurzer ehrlicher Check\? \$\{summarySentence\}`, directWhatsappUrl\),/,
`href: buildWhatsappHref(context.direct + ' ' + summarySentence, directWhatsappUrl),`
);
playbook = playbook.replace(
/href: buildTelegramHref\(`Kannst du mir kurz ehrliches Feedback geben\? \$\{summarySentence\}`, directTelegramUrl\),/,
`href: buildTelegramHref(context.telegram + ' ' + summarySentence, directTelegramUrl),`
);
playbook = playbook.replace(
/href: buildWhatsappHref\('Brauche einen kurzen Profilbild-Check von ein paar Leuten:', groupWhatsappUrl\),/,
`href: buildWhatsappHref(context.group, groupWhatsappUrl),`
);
playbook = playbook.replace(
/href: buildTelegramHref\('Kurzer Profilbild-Check\. Welche Wirkung hat das Foto auf dich\?', groupTelegramUrl\),/,
`href: buildTelegramHref(context.ask, groupTelegramUrl),`
);
fs.writeFileSync(playbookFile, playbook, 'utf8');
console.log('context invite templates added');