diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3434eb7..1f7ced1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -96,7 +96,7 @@ jobs: run: | # A new role assignment can take a few minutes to apply. for i in $(seq 1 20); do - infra/scripts/bootstrap-secrets.sh "${{ steps.base.outputs.kv }}" site_afterh site_hfriends site_datealittle && exit 0 + infra/scripts/bootstrap-secrets.sh "${{ steps.base.outputs.kv }}" site_afterh site_hfriends site_datealittle site_swingandscore && exit 0 echo "waiting for Key Vault access…"; sleep 30 done exit 1 diff --git a/apps/api/scripts/bootstrap.ts b/apps/api/scripts/bootstrap.ts index efa88cf..e183ffc 100644 --- a/apps/api/scripts/bootstrap.ts +++ b/apps/api/scripts/bootstrap.ts @@ -1,12 +1,13 @@ // First-time setup for a real (prod) environment. Safe to re-run and never deletes anything: // - adds BOOTSTRAP_ADMIN_EMAIL as a Platform Admin (owner of the WhatBox sites) if not there yet -// - creates AfterH, HFriends and DateALittle with their default settings, real domains only and -// no members, unless a site with that id already exists (an existing site is left untouched) +// - creates AfterH, HFriends, DateALittle and SwingAndScore with their default settings, real domains only, +// no members and their starter pages, unless a site with that id already exists (an existing site is left untouched) +// The site's database already exists: the migrate job runs first and creates one for every built-in site. // Runs as the `bootstrap` job, started by the deploy workflow when an admin email is given. -import { seedSites, type Site } from '@whatbox/core'; +import { addStarterPages, seedSites, type Site } from '@whatbox/core'; import { closePools, pool } from '../src/db'; import { config } from '../src/config'; -import { PgControlRepo } from '../src/pg-repo'; +import { PgControlRepo, PgSiteRepo, siteDbName } from '../src/pg-repo'; (async () => { const email = (process.env.BOOTSTRAP_ADMIN_EMAIL ?? '').trim().toLowerCase(); @@ -33,7 +34,9 @@ import { PgControlRepo } from '../src/pg-repo'; createdAt: now.toISOString(), }; await control.saveSite(site); - console.log(`${site.slug}: created (${site.domains.join(', ')})`); + const pages = await addStarterPages(site, new PgSiteRepo(pool(siteDbName(site.slug))), now); + await control.saveSite(site); // remembers which starter pages were added + console.log(`${site.slug}: created (${site.domains.join(', ')}), ${pages.length} pages`); } await closePools(); })().catch((e) => { console.error(e); process.exit(1); }); diff --git a/apps/api/scripts/smoke.ts b/apps/api/scripts/smoke.ts index 1b8e437..642626f 100644 --- a/apps/api/scripts/smoke.ts +++ b/apps/api/scripts/smoke.ts @@ -130,7 +130,7 @@ const base = process.env.API_URL ?? 'http://localhost:4000'; const st = await admin.start(DEMO_OWNER_EMAIL); admin.setToken((await admin.verify(st.challengeId, st.devCode!)).token); const adm = await admin.me(); - assert.equal(adm.sites.length, 3); + assert.equal(adm.sites.length, 4); const queue = await admin.moderation('site_afterh', 'pending'); assert.ok(queue.some((q) => q.kind === 'message' && q.messageBody?.includes('gift card'))); const site2 = await admin.updateSite('site_afterh', { settings: { membership: { paywallEnabled: true } } }); diff --git a/apps/member/src/app/(app)/activity.tsx b/apps/member/src/app/(app)/activity.tsx index 3937938..83a1d30 100644 --- a/apps/member/src/app/(app)/activity.tsx +++ b/apps/member/src/app/(app)/activity.tsx @@ -1,6 +1,6 @@ // Activity: "Liked you" is built for busy inboxes. Priority likes come first, then people who fit // what you asked for, then serious profiles. Quick filters and one-tap like back or pass. -import type { ActivityList, ActivityPerson, Tier } from '@whatbox/core'; +import { agesLabel, type ActivityList, type ActivityPerson, type Tier } from '@whatbox/core'; import { TONES } from '@whatbox/core'; import { router } from 'expo-router'; import { useCallback, useEffect, useMemo, useState } from 'react'; @@ -114,7 +114,7 @@ export default function Activity() { {shown.map((p) => ( - router.push(`/member/${p.id}`)} accessibilityLabel={`${p.displayName}, ${p.age}. Open profile`}> + router.push(`/member/${p.id}`)} accessibilityLabel={`${p.displayName}, ${agesLabel(p)}. Open profile`}> {p.vip ? : null} @@ -124,7 +124,7 @@ export default function Activity() { - {p.displayName}, {p.age} + {p.displayName}, {agesLabel(p)} {p.city} · {relTime(p.at)} {p.fitsMe ? Fits you : null} diff --git a/apps/member/src/app/(app)/browse.tsx b/apps/member/src/app/(app)/browse.tsx index 5861cec..eed90e3 100644 --- a/apps/member/src/app/(app)/browse.tsx +++ b/apps/member/src/app/(app)/browse.tsx @@ -1,4 +1,4 @@ -import { GENDERS, tierFor, type MemberCard, type SearchFilters, type SearchResult } from '@whatbox/core'; +import { agesLabel, COUPLE_MIXES, coupleLabel, GENDERS, tierFor, type MemberCard, type SearchFilters, type SearchResult } from '@whatbox/core'; import { router } from 'expo-router'; import { useCallback, useEffect, useState } from 'react'; import { Platform, Pressable, ScrollView, useWindowDimensions, View } from 'react-native'; @@ -58,7 +58,10 @@ export default function Browse() { }; const filterable = site.fields.filter((f) => f.filterable && (f.type === 'select' || f.type === 'multiselect')); const moreCount = filterable.filter((f) => draft.fields?.[f.key]?.length).length; - const seekingLabel = (me!.member.seeking ?? []).map((v) => GENDERS.find((g) => g.value === v)?.plural ?? v).join(', ') || 'Everyone'; + const seekingLabel = [ + ...(site.couples ? (me!.member.seekingCouples ?? []).map((c) => COUPLE_MIXES.find((x) => x.value === c)?.label ?? c) : []), + ...(me!.member.seeking ?? []).map((v) => { const pl = GENDERS.find((g) => g.value === v)?.plural ?? v; return site.couples ? `Single ${pl.replace(/^(Women|Men)$/, (x) => x.toLowerCase())}` : pl; }), + ].join(', ') || 'Everyone'; const digits = (v: string) => v.replace(/\D/g, '').slice(0, 2); const panel = ( @@ -179,6 +182,7 @@ function PersonCard({ p, width, onLiked }: { p: MemberCard; width: any; onLiked: {p.vip ? : null} {p.online ? : null} {p.isNew ? : null} + {p.couple ? : null} @@ -186,7 +190,7 @@ function PersonCard({ p, width, onLiked }: { p: MemberCard; width: any; onLiked: router.push(`/member/${p.id}`)} style={{ flex: 1 }}> - {p.displayName}, {p.age} + {p.displayName}, {agesLabel(p)} router.push(`/member/${top.id}`)} accessibilityLabel={`Open ${top.displayName}'s full profile`} style={{ padding: 16, gap: 6, backgroundColor: t.surface }}> - {top.displayName}, {top.age} + {top.displayName}, {agesLabel(top)} {top.city}{top.miles !== null ? ` · ${awayLabel(top.miles, me!.member.unitsResolved)}` : ''} {top.facts.length ? {top.facts.join(' · ')} : null} diff --git a/apps/member/src/app/(app)/me.tsx b/apps/member/src/app/(app)/me.tsx index 32ac0e4..67a652e 100644 --- a/apps/member/src/app/(app)/me.tsx +++ b/apps/member/src/app/(app)/me.tsx @@ -1,10 +1,11 @@ -import { ApiError, DEFAULT_NOTIFY, DEFAULT_STRICT, GENDERS, type NotifyPrefs, type AccessRow, type Gender, type Member, type HiddenPrefs, type StrictPrefs } from '@whatbox/core'; +import { agesLabel, ApiError, type CoupleMix, DEFAULT_NOTIFY, DEFAULT_STRICT, GENDERS, type NotifyPrefs, type AccessRow, type Gender, type Member, type HiddenPrefs, type StrictPrefs } from '@whatbox/core'; import { router, useLocalSearchParams } from 'expo-router'; import { useCallback, useEffect, useState } from 'react'; import { Pressable, ScrollView, View } from 'react-native'; import { useBilling } from '../../lib/billing'; import { useSession } from '../../lib/session'; import { FieldsEditor } from '../../ui/FieldsEditor'; +import { CoupleBasics, CoupleFields, partnerDraft, partnerPatch, SeekingBoth, type PartnerDraft } from '../../ui/CoupleEditor'; import { Avatar, Badge, Btn, Card, ChipPicker, ErrorText, Field, H, Notice, relTime, Segmented, Toggle, Txt, useTheme } from '../../ui/kit'; import { LocationPicker, type PickedLocation } from '../../ui/LocationPicker'; import { DISTANCE_STEPS, distanceLabel } from '../../lib/distance'; @@ -59,18 +60,24 @@ function ProfileTab() { const units = m.unitsResolved; const plural = (v: Gender) => GENDERS.find((g) => g.value === v)!.plural; const [fields, setFields] = useState(m.fields); + const [kind, setKind] = useState<'single' | 'couple'>(m.kind ?? 'single'); + const [partner, setPartner] = useState(partnerDraft(m.partner)); + const [seekingCouples, setSeekingCouples] = useState(m.seekingCouples ?? []); const [busy, setBusy] = useState(false); const [msg, setMsg] = useState(null); const [error, setError] = useState(null); return ( - + {site.couples ? : null} + Who you want to meet Discover and Browse start from these. A hard limit is never crossed. A preferred one widens when you run out of people, and those people are labelled. - g.plural)} value={seeking.map(plural)} - onChange={(ls: string[]) => ls.length && setSeeking(ls.map((l) => GENDERS.find((g) => g.plural === l)!.value))} /> + {site.couples ? : ( + g.plural)} value={seeking.map(plural)} + onChange={(ls: string[]) => ls.length && setSeeking(ls.map((l) => GENDERS.find((g) => g.plural === l)!.value))} /> + )} setStrict({ ...strict, seeking: v })} /> setHidden({ ...hidden, seeking: v })} /> @@ -84,14 +91,15 @@ function ProfileTab() { setStrict({ ...strict, distance: v })} /> About you on {site.name} - + {site.couples ? : } {msg ? {msg} : null} { setBusy(true); setError(null); setMsg(null); try { - setMe(await api.updateMe({ displayName: name, about, ...(loc ? { location: loc.input } : {}), seeking, ageMin: Number(ageMin) || m.ageMin, ageMax: Number(ageMax) || m.ageMax, maxMiles: miles, strict, hiddenPrefs: hidden, showEvents, fields })); + setMe(await api.updateMe({ displayName: name, about, ...(loc ? { location: loc.input } : {}), seeking, ageMin: Number(ageMin) || m.ageMin, ageMax: Number(ageMax) || m.ageMax, maxMiles: miles, strict, hiddenPrefs: hidden, showEvents, fields, + ...(site.couples ? { kind, seekingCouples, ...(kind === 'couple' ? { partner: partnerPatch(partner) } : {}) } : {}) })); setMsg('Saved.'); } catch (e) { setError(e instanceof ApiError ? e.message : 'Could not save.'); } finally { setBusy(false); } }} /> @@ -116,7 +124,7 @@ function AccessTab() { router.push(`/member/${r.member.id}`)} style={{ flexDirection: 'row', alignItems: 'center', gap: 12, flex: 1, minWidth: 180 }}> - {r.member.displayName}, {r.member.age} + {r.member.displayName}, {agesLabel(r.member)} {status} · {relTime(r.updatedAt)} diff --git a/apps/member/src/app/(app)/member/[id].tsx b/apps/member/src/app/(app)/member/[id].tsx index a34beaf..5d237e4 100644 --- a/apps/member/src/app/(app)/member/[id].tsx +++ b/apps/member/src/app/(app)/member/[id].tsx @@ -1,4 +1,4 @@ -import { ApiError, GENDERS, type MemberProfile, type PhotoView } from '@whatbox/core'; +import { agesLabel, ApiError, COUPLE_MIXES, coupleLabel, GENDERS, type MemberProfile, type PhotoView } from '@whatbox/core'; import { router, useLocalSearchParams } from 'expo-router'; import { useCallback, useEffect, useState } from 'react'; import { Pressable, ScrollView, View } from 'react-native'; @@ -40,7 +40,8 @@ export default function ProfileScreen() { }[p.privateAccess]; const preview = !!p.preview; const lookingFor = [ - p.seeking ? p.seeking.map((s) => GENDERS.find((g) => g.value === s)?.plural ?? s).join(', ') : '', + ...(p.seekingCouples ?? []).map((c) => COUPLE_MIXES.find((x) => x.value === c)?.short.replace('couple', 'couples') ?? c), + p.seeking ? p.seeking.map((s) => (p.seekingCouples ? 'single ' : '') + (GENDERS.find((g) => g.value === s)?.plural ?? s).replace(/^(Women|Men)$/, (x) => (p.seekingCouples ? x.toLowerCase() : x))).join(', ') : '', p.ageMin !== undefined ? `${p.ageMin} to ${p.ageMax}` : '', ].filter(Boolean).join(', '); const all = [p.mainPhoto, ...p.publicPhotos].filter(Boolean) as PhotoView[]; @@ -116,7 +117,7 @@ export default function ProfileScreen() { - {p.displayName}, {p.age} + {p.displayName}, {agesLabel(p)} {p.tier === 'vip' ? : null} {p.verified ? ( @@ -125,6 +126,7 @@ export default function ProfileScreen() { ) : null} + {p.couple ? {coupleLabel(p)} : null} {[p.city, p.region].filter(Boolean).join(', ')}{p.miles !== null ? ` · ${awayLabel(p.miles, me!.member.unitsResolved, true)}` : ''}{p.online ? ' · Online now' : ''} @@ -191,6 +193,17 @@ export default function ProfileScreen() { ) : null} + {p.people?.map((who, i) => ( + + {who.name || (i === 0 ? 'Partner one' : 'Partner two')} + + + g.value === who.gender)?.label ?? who.gender} /> + {who.details.map((d) => )} + + + ))} + {p.events?.length ? ( Events diff --git a/apps/member/src/app/(app)/messages/[id].tsx b/apps/member/src/app/(app)/messages/[id].tsx index fcca868..070c450 100644 --- a/apps/member/src/app/(app)/messages/[id].tsx +++ b/apps/member/src/app/(app)/messages/[id].tsx @@ -1,4 +1,4 @@ -import { ApiError, type ConversationView } from '@whatbox/core'; +import { agesLabel, ApiError, type ConversationView } from '@whatbox/core'; import { router, useLocalSearchParams } from 'expo-router'; import { useCallback, useEffect, useRef, useState } from 'react'; import { KeyboardAvoidingView, Platform, Pressable, ScrollView, TextInput, View } from 'react-native'; @@ -48,7 +48,7 @@ export default function Conversation() { router.push(`/member/${other.id}`)} style={{ flexDirection: 'row', alignItems: 'center', gap: 10, flex: 1 }}> - {other.displayName}, {other.age} + {other.displayName}, {agesLabel(other)} {other.online ? 'Online now' : other.city} diff --git a/apps/member/src/app/(app)/messages/index.tsx b/apps/member/src/app/(app)/messages/index.tsx index cf4b6f2..2ee43a9 100644 --- a/apps/member/src/app/(app)/messages/index.tsx +++ b/apps/member/src/app/(app)/messages/index.tsx @@ -1,4 +1,4 @@ -import type { ConversationSummary } from '@whatbox/core'; +import { agesLabel, type ConversationSummary } from '@whatbox/core'; import { router } from 'expo-router'; import { useEffect, useState } from 'react'; import { Pressable, ScrollView, View } from 'react-native'; @@ -33,7 +33,7 @@ export default function Messages() { - {c.other.displayName}, {c.other.age} + {c.other.displayName}, {agesLabel(c.other)} {c.fromVip ? : null} {relTime(c.last.at)} diff --git a/apps/member/src/app/onboarding.tsx b/apps/member/src/app/onboarding.tsx index e8f62a2..4930c53 100644 --- a/apps/member/src/app/onboarding.tsx +++ b/apps/member/src/app/onboarding.tsx @@ -1,10 +1,11 @@ -import { ApiError, GENDERS, type Gender, type Member } from '@whatbox/core'; +import { ApiError, GENDERS, type CoupleMix, type Gender, type Member } from '@whatbox/core'; import { Redirect, router } from 'expo-router'; import { useState } from 'react'; import { View } from 'react-native'; import { IS_PREVIEW } from '../lib/backend'; import { useSession } from '../lib/session'; import { AuthFrame } from '../ui/AuthFrame'; +import { CoupleFields, KindPicker, PartnerBasics, partnerDraft, partnerPatch, SeekingBoth, type PartnerDraft } from '../ui/CoupleEditor'; import { FieldsEditor } from '../ui/FieldsEditor'; import { Btn, ChipPicker, ErrorText, Eyebrow, Field, H, Notice, Txt } from '../ui/kit'; import { PhotoManager } from '../ui/PhotoManager'; @@ -33,6 +34,10 @@ export default function Onboarding() { const [miles, setMiles] = useState(50); const [fields, setFields] = useState(me?.member.fields ?? {}); const [about, setAbout] = useState(''); + // Couple sites only + const [kind, setKind] = useState<'single' | 'couple'>(me?.member.kind ?? 'couple'); + const [partner, setPartner] = useState(partnerDraft(me?.member.partner)); + const [seekingCouples, setSeekingCouples] = useState(me?.member.seekingCouples ?? []); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); @@ -54,13 +59,25 @@ export default function Onboarding() { Step 2 of 4 The basics - Only your display name, age and city appear on your card. + Only your display name, {site.couples ? 'ages' : 'age'} and city appear on your card. - + {site.couples ? : null} + {site.couples && kind === 'couple' ? Partner one : null} + setYear(v.replace(/\D/g, '').slice(0, 4))} placeholder="1988" keyboardType="number-pad" hint="You must be 18 or older. Only your age is shown." /> - g.label)} value={gender ? label(gender) : undefined} onChange={(v: string) => setGender(GENDERS.find((g) => g.label === v)!.value)} /> - g.label)} value={seeking.map(label)} onChange={(v: string[]) => setSeeking(v.map((x) => GENDERS.find((g) => g.label === x)!.value))} /> - Pick all that apply. + g.label)} value={gender ? label(gender) : undefined} onChange={(v: string) => setGender(GENDERS.find((g) => g.label === v)!.value)} /> + {site.couples ? ( + <> + {kind === 'couple' ? : null} + {kind === 'couple' ? 'We want to meet' : 'I want to meet'} + + + ) : ( + <> + g.label)} value={seeking.map(label)} onChange={(v: string[]) => setSeeking(v.map((x) => GENDERS.find((g) => g.label === x)!.value))} /> + Pick all that apply. + + )} setAgeMin(v.replace(/\D/g, '').slice(0, 2))} placeholder={String(defaultAges(year)[0])} keyboardType="number-pad" /> setAgeMax(v.replace(/\D/g, '').slice(0, 2))} placeholder={String(defaultAges(year)[1])} keyboardType="number-pad" /> @@ -70,10 +87,12 @@ export default function Onboarding() { Browse and Discover start from these choices. You can change them any time. { - if (!gender || !seeking.length) { setError('Choose who you are and who you want to meet.'); return; } + if (!gender || !(seeking.length || (site.couples && seekingCouples.length))) { setError('Choose who you are and who you want to meet.'); return; } + if (site.couples && kind === 'couple' && (!partner.gender || !partner.year)) { setError("Add partner two's birth year and gender."); return; } if (!loc) { setError('Tell us where you live so we can show people near you.'); return; } const [dMin, dMax] = defaultAges(year); - save(3, { displayName: name, birthYear: Number(year), gender, seeking, location: loc.input, ageMin: Number(ageMin) || dMin, ageMax: Number(ageMax) || dMax, maxMiles: miles }); + const couple = site.couples ? { kind, seekingCouples, ...(kind === 'couple' ? { partner: partnerPatch(partner) } : {}) } : {}; + save(3, { displayName: name, birthYear: Number(year), gender, seeking, ...couple, location: loc.input, ageMin: Number(ageMin) || dMin, ageMax: Number(ageMax) || dMax, maxMiles: miles }); }} /> ) : null} @@ -82,13 +101,13 @@ export default function Onboarding() { Step 3 of 4 - About you + {site.couples && kind === 'couple' ? 'About you two' : 'About you'} Share as much or as little as you like. You can change this later. - - + {site.couples ? : } + - save(4, { fields, about })} /> + save(4, { fields, about, ...(site.couples && kind === 'couple' ? { partner: partnerPatch(partner) } : {}) })} /> ) : null} diff --git a/apps/member/src/ui/CoupleEditor.tsx b/apps/member/src/ui/CoupleEditor.tsx new file mode 100644 index 0000000..c51fca8 --- /dev/null +++ b/apps/member/src/ui/CoupleEditor.tsx @@ -0,0 +1,80 @@ +// Couple sites (SwingAndScore): single or couple, the second person's details, and who to meet, +// singles and couples. Other sites never show any of this. +import { COUPLE_MIXES, GENDERS, type CoupleMix, type Gender, type Member, type Partner, type ProfileFieldDef } from '@whatbox/core'; +import { View } from 'react-native'; +import { FieldsEditor } from './FieldsEditor'; +import { ChipPicker, Field, H, Txt } from './kit'; + +export interface PartnerDraft { name: string; gender?: Gender; year: string; fields: Member['fields'] } +export const partnerDraft = (p?: Partner): PartnerDraft => ({ name: p?.name ?? '', gender: p?.gender, year: p ? String(p.birthYear) : '', fields: { ...p?.fields } }); +export const partnerPatch = (d: PartnerDraft) => ({ + name: d.name, gender: d.gender, birthYear: Number(d.year), + fields: Object.fromEntries(Object.entries(d.fields).filter(([, v]) => v !== undefined && v !== '')), +}); + +const glabel = (v: Gender) => GENDERS.find((g) => g.value === v)!.label; + +/** "A couple" or "Just me". */ +export function KindPicker({ kind, onKind }: { kind: 'single' | 'couple'; onKind: (k: 'single' | 'couple') => void }) { + return onKind(v === 'A couple' ? 'couple' : 'single')} />; +} + +/** The second person on a couple profile: name, birth year and gender. */ +export function PartnerBasics({ partner, onPartner }: { partner: PartnerDraft; onPartner: (p: PartnerDraft) => void }) { + return ( + + Partner two + onPartner({ ...partner, name: v })} maxLength={24} /> + onPartner({ ...partner, year: v.replace(/\D/g, '').slice(0, 4) })} placeholder="1988" keyboardType="number-pad" hint="Both of you must be 18 or older." /> + g.label)} value={partner.gender ? glabel(partner.gender) : undefined} + onChange={(v: string) => onPartner({ ...partner, gender: GENDERS.find((g) => g.label === v)!.value })} /> + + ); +} + +/** Both of the above, for the profile editor. */ +export function CoupleBasics({ kind, onKind, partner, onPartner }: { + kind: 'single' | 'couple'; onKind: (k: 'single' | 'couple') => void; partner: PartnerDraft; onPartner: (p: PartnerDraft) => void; +}) { + return ( + + + {kind === 'couple' ? : null} + + ); +} + +/** Who to meet on a couple site: couples by combination, and singles by gender. */ +export function SeekingBoth({ seeking, onSeeking, couples, onCouples }: { + seeking: Gender[]; onSeeking: (g: Gender[]) => void; couples: CoupleMix[]; onCouples: (c: CoupleMix[]) => void; +}) { + const single = (v: Gender) => `Single ${GENDERS.find((g) => g.value === v)!.plural.replace(/^(Women|Men)$/, (x) => x.toLowerCase())}`; + return ( + + c.label)} value={couples.map((c) => COUPLE_MIXES.find((x) => x.value === c)!.label)} + onChange={(ls: string[]) => onCouples(ls.map((l) => COUPLE_MIXES.find((x) => x.label === l)!.value))} /> + single(g.value))} value={seeking.map(single)} + onChange={(ls: string[]) => onSeeking(ls.map((l) => GENDERS.find((g) => single(g.value) === l)!.value))} /> + Pick all that apply, at least one. + + ); +} + +/** Profile fields: shared ones once, then per-person ones for each partner (or just once for a single). */ +export function CoupleFields({ fields, value, onChange, kind, partner, onPartner }: { + fields: ProfileFieldDef[]; value: Member['fields']; onChange: (v: Member['fields']) => void; + kind: 'single' | 'couple'; partner: PartnerDraft; onPartner: (p: PartnerDraft) => void; +}) { + if (kind !== 'couple') return ; + const each = fields.filter((f) => f.perPerson), shared = fields.filter((f) => !f.perPerson); + return ( + + Partner one + + {partner.name.trim() || 'Partner two'} + onPartner({ ...partner, fields: f })} /> + About you both + + + ); +} diff --git a/apps/member/src/ui/PrototypeBar.tsx b/apps/member/src/ui/PrototypeBar.tsx index 5df7b52..bcae266 100644 --- a/apps/member/src/ui/PrototypeBar.tsx +++ b/apps/member/src/ui/PrototypeBar.tsx @@ -9,6 +9,7 @@ const SITES = [ { key: 'afterh', label: 'AfterH' }, { key: 'hfriends', label: 'HFriends' }, { key: 'datealittle', label: 'DateALittle' }, + { key: 'swingandscore', label: 'SwingAndScore' }, ]; export function PrototypeBar() { diff --git a/packages/core/src/articles/swingandscore.ts b/packages/core/src/articles/swingandscore.ts new file mode 100644 index 0000000..6d70af5 --- /dev/null +++ b/packages/core/src/articles/swingandscore.ts @@ -0,0 +1,450 @@ +// SwingAndScore article library: public guides for couples and singles in the swinger lifestyle. +// Everything here is safe for work and crawlable: frank about the lifestyle, never explicit. +// No member photos, no product links, and nothing that reads as offering paid meetups. +import { article, type PageDraft } from '../content'; +import type { Site } from '../types'; + +const REVIEWED = '2026-11-29'; + +export function swingandscoreArticles(site: Site): PageDraft[] { + const n = site.name; + return [ + // ---------- Getting started ---------- + article({ + slug: 'swinging-for-beginners', category: 'Getting started', title: 'Swinging for beginners: a guide for curious couples', reviewedAt: REVIEWED, + summary: 'Talking about it, setting boundaries, and taking the first small step.', + seoTitle: 'Swinging for beginners: how curious couples get started', + seoDescription: 'New to the swinger lifestyle? How to talk about it as a couple, set boundaries, and take a low-pressure first step together.', + related: ['talking-to-your-partner-about-swinging', 'setting-boundaries-as-a-couple', 'first-meet-and-greet'], + body: ` + Most couples in the lifestyle started exactly where you are: curious, a little nervous, and not sure how to bring it up. + + ## Talk first, then talk again + Share what interests you and what does not. Fantasies are a fine starting point, but a real conversation about feelings, jealousy and limits matters more. + + ## Agree on your boundaries + Many couples start with a simple list: what is fine, what is a maybe, and what is off the table. Write it down, and agree that either of you can change it at any time. + + ## Start small + A drink with another couple, a social at a lifestyle club, or simply chatting online is a great first step. Nothing has to happen. + + ## Check in afterwards + Talk about what you enjoyed and what felt uncomfortable. The couples who last in the lifestyle are the ones who keep talking. + `, + }), + article({ + slug: 'soft-swap-vs-full-swap', category: 'Getting started', title: 'Soft swap vs full swap: what the terms mean', reviewedAt: REVIEWED, + summary: 'A plain-language guide to the words you will see on profiles.', + seoTitle: 'Soft swap vs full swap and other swinger terms explained', + seoDescription: 'What soft swap, full swap, same room and other common swinger terms mean, so you can read profiles and set clear expectations.', + related: ['swinger-glossary', 'setting-boundaries-as-a-couple', 'writing-a-great-swinger-profile'], + body: ` + Profiles use a short vocabulary to say what people are into. Knowing it saves a lot of awkward questions. + + ## Soft swap + Usually means some play with other people, but stopping short of sex with anyone other than your own partner. Exactly where the line sits varies, so ask. + + ## Full swap + Partners are open to sex with others. + + ## Same room and separate room + Whether couples stay together or are fine being apart. + + ## Friends first + People who want to get to know you socially before anything else happens. + + Every couple defines these a little differently. Use the terms to start a conversation, never to skip one. + `, + }), + article({ + slug: 'swinger-glossary', category: 'Getting started', title: 'The swinger glossary: lifestyle terms A to Z', reviewedAt: REVIEWED, + summary: 'Unicorns, hotwives, takeovers and more, explained without the jargon.', + seoTitle: 'Swinger glossary: common lifestyle terms explained', + seoDescription: 'A plain-language glossary of swinger lifestyle terms, from soft swap and full swap to unicorn, vanilla, takeover and on-premise club.', + related: ['soft-swap-vs-full-swap', 'swinging-for-beginners', 'lifestyle-clubs-and-parties'], + body: ` + The lifestyle has its own shorthand. Here are the terms you will see most on profiles and at events. + + The lifestyle + The common name for swinging and consensual non-monogamy among couples and the singles they meet. + + Vanilla + Someone not in the lifestyle, or an activity with no swinging involved. It is not an insult. + + Soft swap and full swap + How far couples go with other people. See [our guide](/soft-swap-vs-full-swap) for the details. + + Unicorn + A single woman who meets couples. The name comes from how rare couples once said they were. Many single women dislike being "hunted", so read [our guide for couples](/couples-finding-a-third) first. + + Bull + A single man who meets couples, usually at the couple's invitation. + + Hotwife + A married woman who sees other people with her partner's enthusiastic agreement. + + On-premise and off-premise + An on-premise club has private areas for play. An off-premise club is a social venue: people meet there and go elsewhere. + + Takeover + When a lifestyle group books a whole resort, hotel or cruise for its members. + + Meet and greet + A casual social event, usually in a bar or restaurant, for meeting people with no expectations. + `, + }), + article({ + slug: 'writing-a-great-swinger-profile', category: 'Getting started', title: 'Writing a couple or single profile people want to answer', reviewedAt: REVIEWED, + summary: 'Be specific, be honest, and say what you are looking for.', + seoTitle: 'How to write a great swinger profile as a couple or single', + seoDescription: 'Tips for a swinger profile that gets replies: an honest About us, clear interests and boundaries, current photos and a friendly opening line.', + related: ['choosing-profile-photos', 'soft-swap-vs-full-swap', 'first-messages-that-get-replies'], + body: ` + Your profile does the introducing for you. A good one saves everyone time and brings you the right messages. + + ## Write the About us together + If you are a couple, write it together. People can tell when one partner wrote it alone, and they want to know you are both interested. + + ## Be specific + "Fun couple looking for fun" says nothing. Say what you enjoy outside the bedroom, how experienced you are, and what kind of people you click with. + + ## Say what you are looking for, and what you are not + Use the interests and boundaries on your profile. Clear limits are attractive, not off-putting. + + ## Keep it current + Real ages, recent photos and an honest description of where you are in the lifestyle. Surprises at a first meeting rarely go well. + + ## Keep it friendly + Avoid long lists of rules or demands. A warm tone gets far more replies. + `, + }), + + // ---------- Relationships ---------- + article({ + slug: 'talking-to-your-partner-about-swinging', category: 'Relationships', title: 'How to bring up swinging with your partner', reviewedAt: REVIEWED, + summary: 'Choosing the moment, starting with curiosity, and listening to the answer.', + seoTitle: 'How to talk to your partner about swinging', + seoDescription: 'How to raise the idea of swinging with a partner: pick a calm moment, start with curiosity, listen without pressure and take things slowly.', + related: ['swinging-for-beginners', 'setting-boundaries-as-a-couple', 'handling-jealousy'], + body: ` + Bringing up the lifestyle can feel risky. Done gently, it is just another honest conversation between two people who trust each other. + + ## Pick a calm moment + Not during an argument, not right after sex, and not after a few drinks. A relaxed evening at home works better. + + ## Start with curiosity + Something you read, a show you watched, or a fantasy you have both joked about can open the door without putting anyone on the spot. + + ## Listen more than you talk + Your partner may be excited, uncertain or uncomfortable. All of those are fair. A "no" or a "not now" is an answer to respect, not a problem to solve. + + ## Take it slowly + Plenty of couples talk for months before they do anything. Reading together, chatting with other couples online or going to a social is a gentle next step. + `, + }), + article({ + slug: 'setting-boundaries-as-a-couple', category: 'Relationships', title: 'Setting boundaries as a couple', reviewedAt: REVIEWED, + summary: 'Yes, no and maybe lists, check-in signals, and changing your mind.', + seoTitle: 'Setting boundaries as a swinging couple: a practical guide', + seoDescription: 'How swinging couples set boundaries that work: yes, no and maybe lists, check-in signals, veto rules, and how to revisit limits as you grow.', + related: ['talking-to-your-partner-about-swinging', 'handling-jealousy', 'swinger-etiquette'], + body: ` + Clear boundaries are what make the lifestyle feel safe and fun for both partners. + + ## Yes, no and maybe + Make three lists together: things you are both happy with, things that are off the table, and things you might try later. Keep it somewhere you can revisit it. + + ## Agree on a signal + A word or gesture that means "let's take a break" or "let's go home". Either partner can use it at any time, with no questions asked in the moment. + + ## Decide how vetoes work + Most couples agree that either partner can say no to a person or situation, without having to justify it. + + ## Revisit often + Boundaries change with experience. Talk again after every meeting, and never stretch a limit in the moment. + `, + }), + article({ + slug: 'handling-jealousy', category: 'Relationships', title: 'Handling jealousy in the lifestyle', reviewedAt: REVIEWED, + summary: 'Jealousy is normal. What matters is how you talk about it.', + seoTitle: 'Handling jealousy when you are new to swinging', + seoDescription: 'Jealousy is common for swinging couples, especially at first. How to notice it, talk about it without blame, and adjust your boundaries.', + related: ['setting-boundaries-as-a-couple', 'talking-to-your-partner-about-swinging', 'swinging-for-beginners'], + body: ` + Almost everyone in the lifestyle feels jealous at some point. It does not mean you are doing it wrong. + + ## Notice it early + Jealousy often shows up as irritation, quietness or wanting to leave. Saying "I am feeling a bit jealous" out loud takes a lot of its power away. + + ## Talk without blame + Focus on what you felt and what would help, not on what your partner did wrong. "I felt left out when..." works better than "You always...". + + ## Adjust, then try again + Same room instead of separate rooms, a slower pace, or more time together afterwards can all help. There is no rush. + + ## Know when to pause + If jealousy keeps returning, step back for a while. The lifestyle should add to your relationship, never put it at risk. + `, + }), + article({ + slug: 'couples-finding-a-third', category: 'Relationships', title: 'How couples find a third, respectfully', reviewedAt: REVIEWED, + summary: 'What singles wish couples knew, and how to be a couple people want to meet.', + seoTitle: 'How couples find a third: a respectful guide', + seoDescription: 'Looking for a third as a couple? What singles wish couples knew, how to write your profile, and how to make the first meeting comfortable for everyone.', + related: ['single-women-in-the-lifestyle', 'single-men-in-the-lifestyle', 'first-meet-and-greet'], + body: ` + Many couples want to meet a single woman or man. The ones who succeed treat that person as a person, not an accessory. + + - Be honest about what you are looking for, and about any rules you have as a couple, before you meet. + - Make sure both of you are equally interested. Singles can tell when one partner is just going along with it. + - Let the single person set the pace. They are taking the bigger risk, so their comfort comes first. + - Keep your profile current and real, with photos of both of you. Singles pass over couple profiles that show only one partner. + `, + }), + + // ---------- Singles ---------- + article({ + slug: 'single-women-in-the-lifestyle', category: 'Singles', title: 'Single women in the lifestyle: a guide', reviewedAt: REVIEWED, + summary: 'You set the pace. How to find couples worth meeting and stay in control.', + seoTitle: 'Single women in the swinger lifestyle: a practical guide', + seoDescription: 'A guide for single women meeting couples: choosing who to talk to, staying in control of the pace, safety habits and red flags to watch for.', + related: ['couples-finding-a-third', 'staying-safe-when-meeting', 'first-messages-that-get-replies'], + body: ` + Single women are welcome and in demand in the lifestyle. That gives you a lot of choice, and the right to be choosy. + + ## Choose couples who are both in + Talk to both partners, together, before you meet. If only one of them ever messages, that is worth noticing. + + ## You set the pace + A drink first, no expectations. You can leave at any point, and a good couple will make that easy. + + ## Watch for red flags + Pressure to meet quickly, rules that only ever protect the couple, or a refusal to video chat are all reasons to move on. + + ## Safety habits + Meet in public first, arrange your own way home, and tell a friend where you will be. + `, + }), + article({ + slug: 'single-men-in-the-lifestyle', category: 'Singles', title: 'Single men in the lifestyle: how to be welcome', reviewedAt: REVIEWED, + summary: 'Patience, manners and an honest profile go a long way.', + seoTitle: 'Single men in the swinger lifestyle: how to be welcome', + seoDescription: 'Advice for single men in the lifestyle: an honest profile, respectful messages, patience, and why couples say manners matter more than anything.', + related: ['couples-finding-a-third', 'first-messages-that-get-replies', 'swinger-etiquette'], + body: ` + Single men far outnumber everyone else in the lifestyle, so the ones who stand out are the ones with good manners. + + ## Write a real profile + A clear face photo, a few sentences about who you are outside the lifestyle, and what you are looking for. No explicit photos as your main picture. + + ## Message the couple, not just one partner + Address both of them. Read their profile and mention something specific. + + ## Be patient + Couples take their time and say no often. A polite "thanks anyway" leaves the door open for later. + + ## Respect the rules + Many clubs and events limit single men or require an invitation. Follow the rules and you will be invited back. + `, + }), + article({ + slug: 'first-messages-that-get-replies', category: 'Singles', title: 'First messages that get replies', reviewedAt: REVIEWED, + summary: 'Short, specific and friendly beats long, generic and pushy.', + seoTitle: 'Swinger first messages: what to write to get a reply', + seoDescription: 'How to write a first message on a swinger site that gets answered: read the profile, be specific and friendly, keep it short and never push.', + related: ['writing-a-great-swinger-profile', 'single-men-in-the-lifestyle', 'swinger-etiquette'], + body: ` + A good first message is short, friendly and shows you actually read the profile. + + - Mention something specific from their profile: a shared interest, a place, a joke. + - Say a little about yourselves, or yourself, and what you are hoping for. + - Ask an easy question they can answer in a line. + - Keep it clean. Explicit first messages are the fastest way to be ignored or reported. + - If there is no reply, move on. Repeated messages to someone who has not answered are against our guidelines. + `, + }), + + // ---------- Etiquette ---------- + article({ + slug: 'swinger-etiquette', category: 'Etiquette', title: 'Swinger etiquette: the unwritten rules', reviewedAt: REVIEWED, + summary: 'Consent, honesty and manners that make people want to meet you again.', + seoTitle: 'Swinger etiquette: the unwritten rules of the lifestyle', + seoDescription: 'The etiquette every swinger should know: consent, honest profiles, first meetings, and how to say no thanks gracefully.', + related: ['first-meet-and-greet', 'setting-boundaries-as-a-couple', 'staying-discreet'], + body: ` + The lifestyle runs on trust, and good manners are how you earn it. + + - **Consent is everything.** Ask, do not assume. No means no, and anyone can change their mind at any time. + - **Be honest in your profile.** Current photos, real ages, and a clear picture of what you are into. + - **The first meeting is just a drink.** No expectations, no pressure. + - **Say no kindly, and take no gracefully.** "Thanks, but we do not feel the spark" is all anyone needs to hear. + - **Discretion goes both ways.** What you learn about other members stays private. + + Our [community guidelines](/community-guidelines) put the most important of these in writing. + `, + }), + article({ + slug: 'first-meet-and-greet', category: 'Etiquette', title: 'Your first meet and greet: what to expect', reviewedAt: REVIEWED, + summary: 'A drink, a chat and no expectations.', + seoTitle: 'First swinger meet and greet: what to expect and how to prepare', + seoDescription: 'Meeting another couple or a single for the first time? Where to meet, what to talk about, how to say no thanks, and what to do afterwards.', + related: ['swinger-etiquette', 'staying-safe-when-meeting', 'swinging-for-beginners'], + body: ` + The first meeting is a chance to see whether you like each other in person. That is all it needs to be. + + ## Meet somewhere public + A bar, a restaurant or a lifestyle social. Choose somewhere you can talk easily. + + ## Talk about everything + Work, travel, how you found the lifestyle. Chemistry shows up in ordinary conversation. + + ## Have an exit line ready + "It was lovely to meet you, we are going to head home" works for everyone. Agree as a couple how you will signal that you want to leave. + + ## Follow up kindly + A short message the next day, whether you want to meet again or not, is good manners. + `, + }), + + // ---------- Events ---------- + article({ + slug: 'lifestyle-clubs-and-parties', category: 'Events', title: 'Lifestyle clubs and parties: what to expect', reviewedAt: REVIEWED, + summary: 'Dress codes, house rules, and why your first visit can be just a drink.', + seoTitle: 'Swinger clubs and lifestyle parties: what to expect', + seoDescription: 'Going to a lifestyle club or party for the first time? Dress codes, house rules, consent, and how to enjoy it with no pressure at all.', + related: ['lifestyle-travel-and-takeovers', 'first-meet-and-greet', 'swinger-glossary'], + body: ` + Lifestyle clubs and house parties are a popular way to meet people in a relaxed, social setting. + + - **Check the house rules first.** Most clubs publish rules on consent, phones and photos. Read them before you go. + - **There is no pressure.** Plenty of people go just to dance, have a drink and people-watch. + - **Respect the "no phones" rule.** Discretion is what makes these places work. + - **Go with a plan as a couple:** your boundaries, a check-in signal, and an agreement to leave together whenever either of you wants. + `, + }), + article({ + slug: 'lifestyle-travel-and-takeovers', category: 'Events', title: 'Lifestyle travel: resorts, cruises and takeovers', reviewedAt: REVIEWED, + summary: 'How lifestyle vacations work, and how to choose one for your first trip.', + seoTitle: 'Lifestyle travel: swinger resorts, cruises and takeovers', + seoDescription: 'How lifestyle resorts, cruises and hotel takeovers work, what to check before booking, and tips for enjoying your first lifestyle vacation.', + related: ['lifestyle-clubs-and-parties', 'staying-discreet', 'setting-boundaries-as-a-couple'], + body: ` + Lifestyle travel is one of the most popular ways for couples to meet people in a relaxed setting. + + ## Resorts + Some resorts are lifestyle-friendly all year. Others host lifestyle weeks. Check which, before you book. + + ## Takeovers and cruises + A group books an entire hotel or ship, so every guest is in the lifestyle. They usually include themed parties and socials. + + ## Before you book + - Read the event's rules on consent, photos and dress code. + - Check reviews from other couples. + - Agree on your boundaries before you travel, not on the plane. + + ## Pace yourselves + A week is a long time. Many couples plan quiet days and nights for just the two of them. + `, + }), + + // ---------- Safety ---------- + article({ + slug: 'staying-safe-when-meeting', category: 'Safety', title: 'Staying safe when you meet someone new', reviewedAt: REVIEWED, + summary: 'Public first meetings, your own way home, and trusting your gut.', + seoTitle: 'Swinger safety tips: meeting new people safely', + seoDescription: 'Simple safety habits for meeting couples and singles from a swinger site: video chat first, meet in public, keep your own transport and trust your gut.', + related: ['staying-discreet', 'first-meet-and-greet', 'spotting-romance-scams'], + body: ` + A few habits make meeting new people much safer. + + - Video chat before you meet. It confirms people are who their photos say they are. + - Meet in public first, and arrange your own way there and back. + - Tell a trusted friend where you will be and when you expect to be home. + - Never send money or gift cards to anyone, whatever the reason. + - If anything feels off, leave, and report the member from their profile. Reports are private. + `, + }), + article({ + slug: 'staying-discreet', category: 'Safety', title: 'Staying discreet in the lifestyle', reviewedAt: REVIEWED, + summary: 'Protecting your privacy online and offline.', + seoTitle: 'How to stay discreet as a swinger: privacy tips', + seoDescription: 'Privacy tips for people in the lifestyle: face-free public photos, private galleries, separate email, careful sharing of real names and what we do.', + related: ['choosing-profile-photos', 'staying-safe-when-meeting', 'swinger-etiquette'], + body: ` + Many people in the lifestyle keep it private from work, family or neighbors. That is completely normal. + + ## Online + - Use a nickname and an email address you keep for the lifestyle. + - Keep face photos in your private photos, and share them only with people you approve. + - Share your real names and phone numbers only once you trust someone. + + ## Offline + Respect other people's privacy the way you want yours respected. What happens at a meeting or event is not for sharing. + + ## What ${n} does + Profiles are only visible to signed-in members, never to search engines. Our emails never mention the lifestyle, and any charge appears under a neutral name. + `, + }), + article({ + slug: 'choosing-profile-photos', category: 'Safety', title: 'Choosing profile photos: public, private and explicit', reviewedAt: REVIEWED, + summary: 'What goes where, and the consent rules for every photo.', + seoTitle: 'Swinger profile photos: public, private and explicit', + seoDescription: 'How to choose swinger profile photos: what belongs in public versus private photos, how explicit photos work, and the consent rules for everyone pictured.', + related: ['staying-discreet', 'writing-a-great-swinger-profile', 'swinger-etiquette'], + body: ` + Photos are the first thing people look at, and the thing most worth getting right. + + ## Public photos + Seen by every signed-in member. Keep them non-explicit. Many members use photos without their face here. + + ## Private photos + Seen only by members you approve, one by one. You can take access away at any time. + + ## Explicit photos + Must be marked explicit and kept private. Members can choose not to see them at all. + + ## Consent comes first + Every photo must show only adults who agreed to it being taken and posted here. Read our [consent and photos page](/consent) for the full rules. + `, + }), + + // ---------- Health ---------- + article({ + slug: 'safer-sex-in-the-lifestyle', category: 'Health', title: 'Safer sex in the lifestyle', reviewedAt: REVIEWED, + summary: 'Testing, protection and how to talk about it without killing the mood.', + seoTitle: 'Safer sex for swingers: testing, protection and honest talk', + seoDescription: 'How people in the swinger lifestyle handle safer sex: regular testing, protection, and having the conversation before you meet.', + related: ['sti-testing-for-the-lifestyle', 'setting-boundaries-as-a-couple', 'first-meet-and-greet'], + body: ` + Health is part of the lifestyle conversation, and the best time to have it is before you meet. + + - Get tested regularly, and be ready to talk about when you were last tested. + - Agree on protection in advance. Many members say so right on their profile. + - Respect a no. If someone wants protection or wants to wait, that is the end of the discussion. + + This is general information, not medical advice. Ask your doctor or a local sexual health clinic for advice that fits you. + `, + }), + article({ + slug: 'sti-testing-for-the-lifestyle', category: 'Health', title: 'STI testing: how often and what to ask for', reviewedAt: REVIEWED, + summary: 'Making testing a habit, and talking about results with confidence.', + seoTitle: 'STI testing for swingers: how often and what to ask for', + seoDescription: 'Why regular STI testing is part of the lifestyle, how to ask a clinic for a full screen, and how to talk about results with partners honestly.', + related: ['safer-sex-in-the-lifestyle', 'staying-safe-when-meeting', 'setting-boundaries-as-a-couple'], + body: ` + Regular testing is one of the simplest ways to look after yourself and the people you meet. + + ## Make it a routine + Many people in the lifestyle test every few months, and before meeting anyone new. Your doctor or clinic can suggest what fits you. + + ## Ask for a full screen + A routine checkup does not always include every test. Tell the clinic you have more than one partner and ask what they recommend. + + ## Talk about results + Sharing when you last tested, and the result, is normal and respected in the lifestyle. If you have a condition, telling people before you meet is the honest thing to do. + + This is general information, not medical advice. + `, + }), + ]; +} diff --git a/packages/core/src/couples.ts b/packages/core/src/couples.ts new file mode 100644 index 0000000..b42f80e --- /dev/null +++ b/packages/core/src/couples.ts @@ -0,0 +1,71 @@ +// Couple profiles: one account for two people, in any combination. Only on sites with settings.couples +// (SwingAndScore). Person one is the member's own gender, birth year and fields; person two is member.partner. +import { COUPLE_MIXES, type CoupleMix, type Gender, type Member, type ProfileFieldDef, type Site } from './types'; + +export const couplesOn = (site: Site) => !!site.settings.couples; +export const isCouple = (m: Pick): boolean => m.kind === 'couple' && !!m.partner; + +const side = (g: Gender): 'f' | 'm' | 'x' => (g === 'woman' || g === 'trans_mtf' ? 'f' : g === 'man' || g === 'trans_ftm' ? 'm' : 'x'); + +export function coupleMix(a: Gender, b: Gender): CoupleMix { + const pair = [side(a), side(b)].sort().join(''); + return pair === 'fm' ? 'mf' : pair === 'ff' ? 'ff' : pair === 'mm' ? 'mm' : 'other'; +} + +export function mixOf(m: Pick): CoupleMix | null { + return isCouple(m) ? coupleMix(m.gender, m.partner!.gender) : null; +} + +/** Ages of everyone on the profile: one for a single, two for a couple. */ +export function agesOf(m: Pick, year: number): number[] { + const ages = [year - m.birthYear]; + if (isCouple(m)) ages.push(year - m.partner!.birthYear); + return ages; +} + +/** A couple fits an age range when either partner does. */ +export function fitsAges(m: Pick, year: number, min: number, max: number): boolean { + return agesOf(m, year).some((a) => a >= min && a <= max); +} + +/** Whether a profile is one of the kinds someone wants to meet. */ +export function seeks(want: { seeking?: Gender[]; seekingCouples?: CoupleMix[] }, m: Pick): boolean { + const mix = mixOf(m); + return mix ? (want.seekingCouples ?? []).includes(mix) : (want.seeking ?? []).includes(m.gender); +} + +/** A field value on a profile: for couples, a per-person field matches if either partner's answer does. */ +export function fieldValues(def: ProfileFieldDef, m: Pick): (string | string[] | number | boolean)[] { + const out = [m.fields[def.key]]; + if (def.perPerson && isCouple(m)) out.push(m.partner!.fields[def.key]); + return out.filter((v) => v !== undefined && v !== ''); +} + +// ---------- SwingAndScore profile fields ---------- + +/** Lifestyle fields for a swingers site. Body details are per person; the rest describe the profile. */ +export function lifestyleFields(start = 1): ProfileFieldDef[] { + let o = start; + return [ + { key: 'orientation', label: 'Orientation', type: 'select', options: ['Straight', 'Bi-curious', 'Bisexual', 'Gay or lesbian', 'Pansexual', 'Prefer not to say'], filterable: true, showOnProfile: true, perPerson: true, section: 'details', order: o++ }, + { key: 'height', label: 'Height', type: 'height', showOnProfile: true, perPerson: true, section: 'details', order: o++ }, + { key: 'body_type', label: 'Body type', type: 'select', options: ['Slim', 'Athletic', 'Average', 'A few extra pounds', 'Curvy', 'Muscular', 'Large'], filterable: true, showOnProfile: true, perPerson: true, section: 'details', order: o++ }, + { key: 'smoking', label: 'Smoking', type: 'select', options: ['Never', 'Sometimes', 'Regularly'], filterable: true, showOnProfile: true, perPerson: true, section: 'details', order: o++ }, + { key: 'experience', label: 'Experience', type: 'select', options: ['New to the lifestyle', 'Some experience', 'Experienced'], filterable: true, showOnProfile: true, section: 'details', order: o++ }, + { key: 'host_travel', label: 'Meeting up', type: 'select', options: ['Can host', 'Can travel', 'Can host or travel', 'Public places first'], filterable: true, showOnProfile: true, section: 'details', order: o++ }, + { key: 'safer_sex', label: 'Safer sex', type: 'select', options: ['Always protection', 'Discuss first', 'Prefer not to say'], showOnProfile: true, section: 'details', order: o++ }, + { key: 'drinking', label: 'Drinking', type: 'select', options: ['Never', 'Socially', 'Regularly'], showOnProfile: true, section: 'details', order: o++ }, + { + key: 'interests', label: 'Into', type: 'multiselect', + options: ['Friends first', 'Soft swap', 'Full swap', 'Same room', 'Separate room', 'Threesomes', 'Groups', 'Watching', 'Being watched', 'Parties', 'Clubs', 'Takeovers and resorts', 'Travel', 'Online only'], + filterable: true, showOnProfile: true, section: 'interests', order: o++, + }, + ]; +} + +/** "40" for a single, "40 & 36" for a couple: what follows the name on cards. */ +export const agesLabel = (c: { age: number; couple?: { ages: [number, number] } }): string => + c.couple ? `${c.couple.ages[0]} & ${c.couple.ages[1]}` : String(c.age); +/** "MF couple" and so on, or '' for a single. */ +export const coupleLabel = (c: { couple?: { mix: CoupleMix } }): string => + c.couple ? COUPLE_MIXES.find((x) => x.value === c.couple!.mix)!.short : ''; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e40c799..4661e06 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,6 +1,7 @@ export * from './types'; export * from './rules'; export * from './niche'; +export * from './couples'; export * from './crypto'; export * from './geo'; export * from './repo'; diff --git a/packages/core/src/seed.ts b/packages/core/src/seed.ts index b797550..500a1e5 100644 --- a/packages/core/src/seed.ts +++ b/packages/core/src/seed.ts @@ -4,6 +4,7 @@ import { DEFAULT_MEMBERSHIP } from './rules'; import { starterPages } from './starter-content'; import { ACCESSIBILITY_FIELD, DATEALITTLE_NICHE, DISABILITY_DETAILS_FIELD, DWARFISM_TYPE_FIELD, HFRIENDS_NICHE, STATURE_FIELD, upgradeNicheFields } from './niche'; import { DEFAULT_LICENSING } from './types'; +import { lifestyleFields } from './couples'; import type { AdminUser, ContentPage, Gender, Member, Message, ModerationItem, Photo, PrivateAccess, ProfileFieldDef, Site, SiteSettings, Tier, View, Like, SiteEvent, EventRsvp, @@ -139,13 +140,27 @@ export function seedSites(now: Date): Site[] { ], ownerIds: ['adm_owner'], createdAt: created, status: 'active', licensing: { ...DEFAULT_LICENSING, owned: true }, }, + { + // Adult site: web only (the apps refuse it), couples and singles, no public teasers, photos reviewed before they show. + id: 'site_swingandscore', slug: 'swingandscore', name: 'SwingAndScore', domains: ['swingandscore.com', 'swingandscore.localhost'], + tagline: 'The lifestyle, minus the guesswork.', + audience: 'For couples and singles in the swinger lifestyle. Adults 18+ only.', + theme: { + ground: '#F7F2F4', surface: '#FFFFFF', ink: '#221722', sub: '#5A4858', line: '#E7DAE2', accent: '#8E2459', + accentSoft: '#F5E3EC', second: '#C8952E', alert: '#9A2E3A', headingFont: 'Fraunces', bodyFont: 'Figtree', radius: 999, style: 'warm', + fontsHref: 'https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Figtree:wght@400;500;600;700&display=swap', + }, + settings: settings({ mode: 'adult', publicTeasers: false, couples: true, photoModeration: 'pre', paymentProvider: 'none' }), + fields: lifestyleFields(1), + ownerIds: ['adm_owner'], createdAt: created, status: 'active', licensing: { ...DEFAULT_LICENSING, owned: true }, + }, ]; } export function seedAdmins(): AdminUser[] { return [ { id: 'adm_platform', email: DEMO_PLATFORM_EMAIL, name: 'WhatBox Platform Admin', role: 'platform', siteIds: [] }, - { id: 'adm_owner', email: DEMO_OWNER_EMAIL, name: 'Site Owner', role: 'owner', siteIds: ['site_afterh', 'site_hfriends', 'site_datealittle'] }, + { id: 'adm_owner', email: DEMO_OWNER_EMAIL, name: 'Site Owner', role: 'owner', siteIds: ['site_afterh', 'site_hfriends', 'site_datealittle', 'site_swingandscore'] }, ]; } @@ -240,6 +255,23 @@ export function seedSite(site: Site, now: Date, opts: { demoMemberHash?: { email createdAt: t(60 * 24 * (3 + Math.floor(r() * 300))), lastActiveAt: online ? t(Math.floor(r() * 10)) : t(30 + Math.floor(r() * 60 * 24 * 6)), }; + if (site.settings.couples) { + // Demo couples: every third profile is two people, in a mix of combinations. + m.seekingCouples = gender === 'nonbinary' ? ['mf', 'ff', 'mm', 'other'] : ['mf']; + if (i % 3 === 0) { + const pg: Gender = i % 9 === 0 ? 'woman' : i % 9 === 3 ? (gender === 'woman' ? 'woman' : 'man') : gender === 'woman' ? 'man' : 'woman'; + const pf: Member['fields'] = {}; + for (const f of fieldDefs) { + if (!f.perPerson) continue; + if (f.type === 'select' && f.options) pf[f.key] = pick(r, f.options); + else if (f.type === 'height') pf[f.key] = (pg === 'man' ? 172 : 158) + ((i * 29) % 21); + } + m.kind = 'couple'; + m.partner = { name: pick(r, pg === 'man' ? MEN : WOMEN), gender: pg, birthYear: year - (age - 3 + Math.floor(r() * 7)), fields: pf }; + m.seeking = ['woman']; + m.seekingCouples = ['mf', 'ff']; + } else m.kind = 'single'; + } if (i % 7 === 5) { m.createdAt = t(60 * 24 * (1 + (i % 9))); m.verifiedAt = m.createdAt; } // a few new members if (name === 'Rosa' && big) { m.about = "Weekend hiker, weekday baker. I was diagnosed a few years ago and it took a while to feel like myself again. Now I'm ready to meet someone kind, curious and up for a sunrise trail now and then."; diff --git a/packages/core/src/services.ts b/packages/core/src/services.ts index 033788c..105db60 100644 --- a/packages/core/src/services.ts +++ b/packages/core/src/services.ts @@ -5,13 +5,14 @@ import { DevKeyProvider, hmacHex, type KeyProvider, randomCode, randomId, SiteCr import { builtinGeo, countryName, unitsForCountry } from './geo'; import { type IpIntel, noteSignIn, riskFlags, riskKey, riskReasons } from './network-risk'; import { memberFlags, type NicheFlag, outsideNiche, textFlags } from './niche'; +import { agesOf, couplesOn, coupleMix, fieldValues, fitsAges, isCouple, seeks } from './couples'; import { buildSiteDashboard, cleanHitPath, combineDashboards, DASHBOARD_DAYS, emptySiteDashboard, isBotAgent, publicGoogleTags, referrerHost, utcDay, addDays, validateGoogleTags, } from './analytics'; import type { ControlRepo, Clock, EventSink, IdTokenVerifier, MailSender, Notifier, PaymentGateway, PhotoStore, SiteProvisioner, SiteRepo } from './repo'; import { campaignProblems, relaunchCopy, renderCampaign, siteAppUrl, type RenderedMail } from './mail'; import { systemClock } from './repo'; -import { DEFAULT_LICENSING, DELETED_RETENTION_DAYS, DEFAULT_NOTIFY, DEFAULT_STRICT, isGender, type HiddenPrefs, type NotifyPrefs, type StrictPrefs } from './types'; +import { DEFAULT_LICENSING, DELETED_RETENTION_DAYS, DEFAULT_NOTIFY, DEFAULT_STRICT, isCoupleMix, isGender, type CoupleMix, type Partner, type PersonView, type ProfileKind, type HiddenPrefs, type NotifyPrefs, type StrictPrefs } from './types'; import { ageFromBirthYear, checkPhotoAllowed, CODE_MAX_ATTEMPTS, CODE_TTL_MS, findContactInfo, formatHeight, maskContactInfo, milesBetween, redactContactInfo, ONLINE_WINDOW_MS, PHOTO_LIMITS, effectivePerms, tierFor, photoVisibleTo, RuleError, scoreCandidate, screenMessage, @@ -87,6 +88,12 @@ export interface ProfilePatch { fields?: Member['fields']; hideExplicit?: boolean; units?: Units; + /** Couple sites: single or couple. */ + kind?: ProfileKind; + /** Couple sites: the second person. fields holds their answers to per-person fields. */ + partner?: Partial; + /** Couple sites: which couples they want to meet. */ + seekingCouples?: CoupleMix[]; /** News and announcement emails from the site. Sign-in codes go out either way. */ emailNews?: boolean; } @@ -153,6 +160,7 @@ export class Platform { publicTeasers: site.settings.mode !== 'sensitive' && site.settings.publicTeasers, units: site.settings.units, nicheIncludeLabel: site.settings.niche?.includeLabel, + couples: couplesOn(site), googleTags: publicGoogleTags(site), }; } @@ -381,6 +389,8 @@ export class Platform { } async memberCtx(site: Site, token: string | null | undefined, platform: ClientPlatform): Promise { + // Adult sites are web only: the iOS and Android apps never open them, whatever a build is pointed at. + if (site.settings.mode === 'adult' && platform !== 'web') throw new RuleError('web_only', `${site.name} is only available on the web.`, 403); if (!token || !token.startsWith(site.slug + '.')) throw new RuleError('signed_out', 'Please sign in.', 401); const repo = await this.repo(site); const s = await repo.getSession(await this.sessionKey(site, token)); @@ -455,6 +465,10 @@ export class Platform { likedByMe: liked.has(m.id), isNew: now.getTime() - Date.parse(m.createdAt) < ctx.site.settings.discover.newMemberDays * 86_400_000, vip: this.tierOf(m) === 'vip', + ...(isCouple(m) ? { couple: { + mix: coupleMix(m.gender, m.partner!.gender), genders: [m.gender, m.partner!.gender] as [Gender, Gender], + ages: [ageFromBirthYear(m.birthYear, now), ageFromBirthYear(m.partner!.birthYear, now)] as [number, number], + } } : {}), }; }); } @@ -513,10 +527,11 @@ export class Platform { m.gender = patch.gender; } if (patch.seeking) { - if (!patch.seeking.length) throw new RuleError('bad_seeking', 'Choose who you want to meet.'); + if (!patch.seeking.length && !couplesOn(ctx.site)) throw new RuleError('bad_seeking', 'Choose who you want to meet.'); if (!patch.seeking.every(isGender)) throw new RuleError('bad_seeking', 'Choose from the listed options.'); m.seeking = [...new Set(patch.seeking)]; } + if (patch.kind !== undefined || patch.partner !== undefined || patch.seekingCouples !== undefined) this.applyCouple(ctx, m, patch, year); if (patch.ageMin !== undefined) m.ageMin = Math.max(18, patch.ageMin); if (patch.ageMax !== undefined) m.ageMax = Math.min(99, patch.ageMax); if (m.ageMin > m.ageMax) [m.ageMin, m.ageMax] = [m.ageMax, m.ageMin]; @@ -554,6 +569,7 @@ export class Platform { for (const [key, value] of Object.entries(patch.fields)) { const def = ctx.site.fields.find((f) => f.key === key); if (!def) throw new RuleError('bad_field', `Unknown field ${key}.`); + if (value === undefined || value === null) { delete m.fields[key]; continue; } // a cleared answer validateField(def, value); m.fields[key] = value; } @@ -564,7 +580,9 @@ export class Platform { if (!m.profileComplete) { const missing = ctx.site.fields.filter((f) => f.required && (m.fields[f.key] === undefined || m.fields[f.key] === '')); - if (m.displayName && m.city && !missing.length) m.profileComplete = true; + const partnerMissing = isCouple(m) && ctx.site.fields.some((f) => f.required && f.perPerson && (m.partner!.fields[f.key] === undefined || m.partner!.fields[f.key] === '')); + const seeksSomeone = m.seeking.length > 0 || (couplesOn(ctx.site) && !!m.seekingCouples?.length); + if (m.displayName && m.city && !missing.length && !partnerMissing && seeksSomeone && (m.kind !== 'couple' || isCouple(m))) m.profileComplete = true; } // Sign-up sets the country after the first sign-in, so compare again whenever it or the profile text changes. if (patch.location || patch.postal !== undefined || patch.about !== undefined) await this.checkRisk(ctx.site, ctx.repo, m); @@ -576,6 +594,52 @@ export class Platform { return this.myProfile(ctx); } + /** Single or couple, the second person's details, and which couples they want to meet. Couple sites only. */ + private applyCouple(ctx: MemberCtx, m: Member, patch: ProfilePatch, year: number) { + if (!couplesOn(ctx.site)) throw new RuleError('no_couples', 'This site has no couple profiles.'); + if (patch.kind !== undefined) { + if (patch.kind !== 'single' && patch.kind !== 'couple') throw new RuleError('bad_kind', 'Choose single or couple.'); + m.kind = patch.kind; + if (patch.kind === 'single') delete m.partner; + } + if (patch.partner !== undefined) { + if (m.kind !== 'couple') throw new RuleError('bad_kind', 'Only couples have a partner on their profile.'); + const cur: Partial = { fields: {}, ...m.partner }; + const p = patch.partner; + if (p.name !== undefined) { + const n = String(p.name).trim(); + if (n.length > NAME_MAX) throw new RuleError('bad_name', `Keep names under ${NAME_MAX} characters.`); + if (/\d{3,}|@|https?:/i.test(n)) throw new RuleError('bad_name', 'Names cannot contain contact details.'); + cur.name = n || undefined; + } + if (p.gender !== undefined) { + if (!isGender(p.gender)) throw new RuleError('bad_gender', 'Choose one of the listed options.'); + cur.gender = p.gender; + } + if (p.birthYear !== undefined) { + // Both people on a couple account must be adults. + if (year - p.birthYear < 18) throw new RuleError('too_young', 'Both partners must be 18 or older.'); + if (year - p.birthYear > 100) throw new RuleError('bad_age', "Check your partner's birth year."); + cur.birthYear = p.birthYear; + } + for (const [key, value] of Object.entries(p.fields ?? {})) { + const def = ctx.site.fields.find((f) => f.key === key && f.perPerson); + if (!def) throw new RuleError('bad_field', `Unknown field ${key}.`); + if (value === undefined || value === null) { delete cur.fields![key]; continue; } // a cleared answer + validateField(def, value); + cur.fields![key] = value; + } + if (!cur.gender || !cur.birthYear) throw new RuleError('bad_partner', "Add your partner's gender and birth year."); + m.partner = cur as Partner; + } + if (patch.seekingCouples !== undefined) { + if (!Array.isArray(patch.seekingCouples) || !patch.seekingCouples.every(isCoupleMix)) throw new RuleError('bad_seeking', 'Choose from the listed options.'); + m.seekingCouples = [...new Set(patch.seekingCouples)]; + } + if (m.kind === 'couple' && !m.partner) throw new RuleError('bad_partner', "Add your partner's gender and birth year."); + if (!m.seeking.length && !m.seekingCouples?.length) throw new RuleError('bad_seeking', 'Choose who you want to meet.'); + } + private async flagProfileText(ctx: MemberCtx, text: string) { const screen = screenMessage({ body: text, site: ctx.site, isNewConversation: false, recentFromSender: [], now: this.now() }); const reasons = [...screen.reasons]; @@ -741,15 +805,19 @@ export class Platform { const dLng = within / (69 * Math.max(0.2, Math.cos((ctx.me.lat * Math.PI) / 180))); bbox = { minLat: ctx.me.lat - dLat, maxLat: ctx.me.lat + dLat, minLng: ctx.me.lng - dLng, maxLng: ctx.me.lng + dLng }; } + // Couple sites filter gender and age here instead: a couple matches on either partner. + const couples = couplesOn(ctx.site); + const want = { seeking: f.seeking ?? ctx.me.seeking, seekingCouples: f.seekingCouples ?? ctx.me.seekingCouples }; let rows = await ctx.repo.queryMembers({ excludeIds: [ctx.me.id, ...blocked], - genders: f.seeking ?? ctx.me.seeking, - birthYearMin: year - ageMax, - birthYearMax: year - ageMin, + genders: couples ? undefined : want.seeking, + birthYearMin: couples ? undefined : year - ageMax, + birthYearMax: couples ? undefined : year - ageMin, activeSince: f.onlineNow ? new Date(now.getTime() - ONLINE_WINDOW_MS).toISOString() : undefined, bbox, onlyComplete: true, }); + if (couples) rows = rows.filter((m) => seeks(want, m) && fitsAges(m, year, ageMin, ageMax)); if (within && bbox) rows = rows.filter((m) => milesBetween(ctx.me, m) <= within); if (!(f.everyone ?? ctx.me.showEveryone)) rows = rows.filter((m) => !outsideNiche(ctx.site, m)); if (f.fields) { @@ -757,11 +825,7 @@ export class Platform { if (!wanted?.length) continue; const def = ctx.site.fields.find((d) => d.key === key && d.filterable); if (!def) continue; - rows = rows.filter((m) => { - const v = m.fields[key]; - if (Array.isArray(v)) return v.some((x) => wanted.includes(x)); - return v !== undefined && wanted.includes(String(v)); - }); + rows = rows.filter((m) => fieldValues(def, m).some((v) => (Array.isArray(v) ? v.some((x) => wanted.includes(x)) : wanted.includes(String(v))))); } } let cards = await this.cards(ctx, rows); @@ -807,7 +871,23 @@ export class Platform { const details: MemberProfile['details'] = []; const cautions: string[] = []; let interests: string[] = []; + const couple = isCouple(m); + const people: PersonView[] = []; + if (couple) { + const now = this.now(); + for (const [i, who] of [{ name: undefined as string | undefined, gender: m.gender, birthYear: m.birthYear, fields: m.fields }, m.partner!].entries()) { + const pd: PersonView['details'] = []; + for (const def of [...ctx.site.fields].sort((a, b) => a.order - b.order)) { + if (!def.perPerson || def.showOnProfile === false) continue; + const v = who.fields[def.key]; + if (v === undefined || v === '') continue; + pd.push({ key: def.key, label: def.label, value: this.fieldText(ctx, def, v) }); + } + people.push({ ...(i === 1 && who.name ? { name: who.name } : {}), gender: who.gender, age: ageFromBirthYear(who.birthYear, now), details: pd }); + } + } for (const def of [...ctx.site.fields].sort((a, b) => a.order - b.order)) { + if (couple && def.perPerson) continue; const v = m.fields[def.key]; if (v === undefined || v === '') continue; if (def.caution && (Array.isArray(v) ? v.includes(def.caution.option) : v === def.caution.option)) cautions.push(def.caution.message); @@ -826,7 +906,8 @@ export class Platform { return { ...card, about: m.about, gender: m.gender, - ...(m.hiddenPrefs?.seeking ? {} : { seeking: m.seeking }), + ...(m.hiddenPrefs?.seeking ? {} : { seeking: m.seeking, ...(couplesOn(ctx.site) ? { seekingCouples: m.seekingCouples ?? [] } : {}) }), + ...(couple ? { people } : {}), ...(m.hiddenPrefs?.ages ? {} : { ageMin: m.ageMin, ageMax: m.ageMax }), ...(preview ? { preview: true } : {}), ...(m.showEvents ? { events: await this.profileEvents(ctx, m.id) } : {}), @@ -1027,26 +1108,25 @@ export class Platform { return { minLat: ctx.me.lat - dLat, maxLat: ctx.me.lat + dLat, minLng: ctx.me.lng - dLng, maxLng: ctx.me.lng + dLng }; }; const inNiche = (m: Member) => !!ctx.me.showEveryone || !outsideNiche(ctx.site, m); - const inPrefs = (m: Member) => { - const age = year - m.birthYear; - return ctx.me.seeking.includes(m.gender) && age >= ctx.me.ageMin && age <= ctx.me.ageMax && (!miles || !hasLoc || milesBetween(ctx.me, m) <= miles); - }; + const couples = couplesOn(ctx.site); + const inPrefs = (m: Member) => seeks(ctx.me, m) && fitsAges(m, year, ctx.me.ageMin, ctx.me.ageMax) && (!miles || !hasLoc || milesBetween(ctx.me, m) <= miles); let rows = (await ctx.repo.queryMembers({ - excludeIds: [...skip], genders: ctx.me.seeking, birthYearMin: year - ctx.me.ageMax, birthYearMax: year - ctx.me.ageMin, + excludeIds: [...skip], genders: couples ? undefined : ctx.me.seeking, + birthYearMin: couples ? undefined : year - ctx.me.ageMax, birthYearMax: couples ? undefined : year - ctx.me.ageMin, bbox: box(miles), onlyComplete: true, })).filter(inPrefs).filter(inNiche); const stretched = new Map(); if (rows.length < limit && !(strict.seeking && strict.age && strict.distance)) { const more = (await ctx.repo.queryMembers({ excludeIds: [...skip, ...rows.map((r) => r.id)], - genders: strict.seeking ? ctx.me.seeking : undefined, - birthYearMin: strict.age ? year - ctx.me.ageMax : undefined, birthYearMax: strict.age ? year - ctx.me.ageMin : undefined, + genders: strict.seeking && !couples ? ctx.me.seeking : undefined, + birthYearMin: strict.age && !couples ? year - ctx.me.ageMax : undefined, birthYearMax: strict.age && !couples ? year - ctx.me.ageMin : undefined, bbox: strict.distance ? box(miles) : undefined, onlyComplete: true, - })).filter((m) => !strict.distance || !miles || !hasLoc || milesBetween(ctx.me, m) <= miles).filter(inNiche); + })).filter((m) => !strict.distance || !miles || !hasLoc || milesBetween(ctx.me, m) <= miles).filter(inNiche) + .filter((m) => (!strict.seeking || seeks(ctx.me, m)) && (!strict.age || fitsAges(m, year, ctx.me.ageMin, ctx.me.ageMax))); for (const m of more) { - const age = year - m.birthYear; - const why = !ctx.me.seeking.includes(m.gender) ? 'Outside who you said you want to meet' - : age < ctx.me.ageMin || age > ctx.me.ageMax ? 'Outside your age range' + const why = !seeks(ctx.me, m) ? 'Outside who you said you want to meet' + : !fitsAges(m, year, ctx.me.ageMin, ctx.me.ageMax) ? 'Outside your age range' : 'Farther than your distance'; stretched.set(m.id, why); } @@ -1150,10 +1230,9 @@ export class Platform { const people: ActivityPerson[] = visible.map((e) => { const m = byId.get(e.id)!; const c = cards.get(e.id)!; - const age = year - m.birthYear; return { ...c, at: e.at, vip: e.vip, - fitsMe: ctx.me.seeking.includes(m.gender) && age >= ctx.me.ageMin && age <= ctx.me.ageMax && (c.miles === null || c.miles <= 100), + fitsMe: seeks(ctx.me, m) && fitsAges(m, year, ctx.me.ageMin, ctx.me.ageMax) && (c.miles === null || c.miles <= 100), serious: !!m.verifiedAt && !!c.mainPhoto && m.about.length >= 60, likedBack: myLikes.has(e.id), }; diff --git a/packages/core/src/starter-content.ts b/packages/core/src/starter-content.ts index d886798..b7b6444 100644 --- a/packages/core/src/starter-content.ts +++ b/packages/core/src/starter-content.ts @@ -7,6 +7,7 @@ import type { PageDraft } from './content'; import { afterhArticles } from './articles/afterh'; import { hfriendsArticles } from './articles/hfriends'; import { datealittleArticles } from './articles/datealittle'; +import { swingandscoreArticles } from './articles/swingandscore'; /** The landing page's editable copy lives in a page with this slug (placement "none", not listed anywhere). */ export const HOME_SLUG = 'home'; @@ -424,6 +425,106 @@ function datealittle(site: Site): Draft[] { ]; } +// ---------- SwingAndScore: adult, for couples and singles in the lifestyle ---------- +// Everything public stays safe for work: frank words, no explicit descriptions, no member photos. + +function swingandscore(site: Site): Draft[] { + const n = site.name; + return [ + { + slug: HOME_SLUG, kind: 'page', title: site.tagline, placement: 'none', + summary: 'Meet couples and singles in the swinger lifestyle near you. Verified adults, couple profiles built for two, and private photos you control.', + seoTitle: `${n}: Swingers dating for couples and singles`, + seoDescription: 'A swingers site for couples and singles: verified adults 18+, real couple profiles for two people, private photos you control. Free to join.', + body: [ + '- Couple profiles built for two: each of you, your own details.', + '- Verified adults only. Scammers and fakes are removed.', + '- Private photos stay private until you say yes.', + '## How it works', + 'Join as a couple or single\nVerify your email or phone with a quick code. Couples share one account, with details for each of you.', + 'Say what you are into\nNew and curious or experienced, soft swap or full swap, host or travel. Clear expectations up front save everyone time.', + 'Meet on your terms\nBrowse couples and singles near you, message the ones who fit, and share private photos only with people you approve.', + '## Why members choose it', + 'Built for couples\nNo more one-person profiles shared by two. Each partner has their own age, height, body type and orientation.', + 'Consent is the rule\nEveryone in every photo is an adult who agreed to it. No means no, and changing your mind is always fine.', + 'Discreet by design\nProfiles are never shown to search engines or visitors, and the site name never appears on your statement.', + 'Real people\nEvery member verifies before they can browse, and our team reviews photos before anyone sees them.', + ].join('\n\n'), + }, + { + slug: 'about', kind: 'page', title: `About ${n}`, placement: 'footer', + summary: `${n} is a community for couples and singles in the swinger lifestyle.`, + seoTitle: `About ${n}`, seoDescription: `Why ${n} exists: a respectful, verified place for couples and singles in the lifestyle to meet.`, + body: [ + `${n} is for adults in the swinger lifestyle: couples of every combination, and the single women and men they want to meet.`, + 'It is built around a few simple ideas. Couples get real couple profiles. Everyone is a verified adult. Photos are reviewed before anyone sees them, and private photos are shared only with members you approve.', + `${n} is run by WhatBox, LLC, and is only available on the web, never in an app store. You must be 18 or older to use it.`, + ].join('\n\n'), + }, + { + slug: 'faq', kind: 'page', title: 'Common questions', placement: 'footer', + summary: 'Answers to what people ask most.', + seoTitle: `${n} questions: couples, singles, privacy and cost`, + seoDescription: `Is ${n} free? How do couple profiles work? Who can see my photos? Answers to the questions people ask most.`, + body: [ + `Is ${n} free?\nYes. Joining, browsing and messaging are free right now.`, + 'How do couple profiles work?\nOne account holds both of you, in any combination. Each of you adds your own age, gender, height, body type and orientation. You share the About us and what you are into.', + 'Can singles join?\nYes. Single women and single men are welcome, as long as they are respectful and honest about who they are.', + 'Who can see our profile?\nOnly verified, signed-in members. Profiles are never shown to visitors or search engines.', + 'Who can see our private photos?\nOnly members you approve, one by one. You can take access away at any time.', + 'Can I hide explicit photos?\nYes. Every member can choose not to see photos marked explicit.', + `Is there an app?\nNo. ${n} is only on the web, and it works well on your phone's browser.`, + `What shows on my bank statement?\nIf you ever upgrade, the charge appears as "${site.settings.billingDescriptor}". The site name never appears.`, + ].join('\n\n'), + }, + { + slug: 'consent', kind: 'page', title: 'Consent and photos', placement: 'footer', + summary: 'The rules for photos, and how to report one that should not be here.', + seoTitle: `Consent and photo rules | ${n}`, + seoDescription: `How ${n} handles photos: adults only, everyone pictured agreed, reviewed before they show, and fast removal on request.`, + body: [ + `Every photo on ${n} must show only adults, 18 or older, who agreed to the photo being taken and to it being posted here.`, + 'When you add a photo marked explicit, you confirm that everyone in it is an adult and agreed to it. We keep a record of that confirmation.', + 'Explicit photos can only be private photos. They are reviewed by our team before anyone sees them, and only members you approve can view them.', + 'Never post a photo of anyone who did not agree to it, a photo taken without someone knowing, or a photo that is not yours.', + 'Is a photo of you here without your consent? Use the report link on the photo, or contact us through the help link. You do not need an account. We remove reported photos while we look into them.', + ].join('\n\n'), + }, + safetyTips(n, [ + 'Agree on your boundaries as a couple before you meet anyone, and agree on a signal to leave.', + 'Meet for a drink first, with no expectations. Chemistry in person matters more than chat.', + 'Talk about safer sex and testing before anything happens, not in the moment.', + ]), + guidelines(n, `${n} is for adults in the swinger lifestyle. These guidelines keep it fun, safe and respectful.`, [ + 'Adults only\nEveryone on the site, and everyone in every photo, must be 18 or older.', + 'Consent, always\nNo means no, maybe means no, and anyone can change their mind at any time. Pressuring anyone gets an account removed.', + 'Be honest\nSingle or couple, ages, photos: all must be real and current. A couple profile must be both of you, and both of you must agree to it.', + 'No paid meetups\nNo escorting, no "generous" arrangements, no asking for or offering money or gifts for a meetup. These accounts are removed.', + 'Respect boundaries\nRespect what a profile says they are and are not into. A polite "no thanks" is the end of the conversation.', + 'Photos you have the right to share\nOnly photos of yourself, or of you and a partner who agreed. Explicit photos go in private photos only.', + ]), + privacy(n, site.settings.billingDescriptor, 'Discretion. Profiles and photos are only shown to signed-in members, never to visitors or search engines. Emails and texts from us never mention the lifestyle.'), + { + slug: 'terms', kind: 'page', title: 'Terms of service', placement: 'footer', + summary: 'The rules for using the site.', + seoTitle: `Terms of service | ${n}`, + seoDescription: `The rules for using ${n}.`, + body: [ + `By creating an account on ${n} you agree to these terms. ${n} is run by WhatBox, LLC.`, + 'You must be 18 or older, and old enough to view adult content where you live. On a couple profile, both people must be 18 or older and both must agree to the profile.', + 'The information in your profile must be true and about you (or both of you).', + 'Be respectful. No harassment, threats or pressure. No asking members for money. No escorting or paid meetups. No advertising or recruiting for other services.', + 'Only post photos you have the right to share, of adults who agreed to them. Explicit photos must be marked explicit and kept private.', + 'We may pause messages for review, remove content, or close accounts that break these rules or put members at risk.', + 'Joining is free. If you buy an upgrade, it renews until you cancel, and you can cancel any time from your settings.', + 'The service is provided as is. Please follow our safety tips and use good judgment when meeting anyone.', + ].join('\n\n'), + }, + scamGuide(n), + ...swingandscoreArticles(site), + ]; +} + // ---------- Any other site: neutral starting text ---------- function generic(site: Site): Draft[] { @@ -450,7 +551,7 @@ function generic(site: Site): Draft[] { /** The starter pages for a site. */ export function starterPages(site: Site, now: Date): ContentPage[] { const at = now.toISOString(); - const drafts = site.slug === 'afterh' ? afterh(site) : site.slug === 'hfriends' ? hfriends(site) : site.slug === 'datealittle' ? datealittle(site) : generic(site); + const drafts = site.slug === 'afterh' ? afterh(site) : site.slug === 'hfriends' ? hfriends(site) : site.slug === 'datealittle' ? datealittle(site) : site.slug === 'swingandscore' ? swingandscore(site) : generic(site); return drafts.map((d) => page(d, at)); } diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 316240e..8c2b37b 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -77,6 +77,8 @@ export interface SiteSettings { mailingAddress?: string; /** Niche sites (DateALittle, HFriends): who Browse shows by default, and which review checks run. */ niche?: NicheSettings; + /** Couple profiles: one account for two people (SwingAndScore). Off unless set. */ + couples?: boolean; } export interface NicheSettings { @@ -136,6 +138,8 @@ export interface ProfileFieldDef { /** text only: longest answer (default 200), and whether it gets a multi-line box. */ maxLength?: number; multiline?: boolean; + /** Couple sites: each partner answers this one (height, body type...). Others are shared by the couple. */ + perPerson?: boolean; } export interface Site { @@ -197,6 +201,27 @@ export const GENDERS: { value: Gender; label: string; plural: string }[] = [ { value: 'trans_ftm', label: 'Trans F2M', plural: 'Trans F2M' }, ]; export const isGender = (v: unknown): v is Gender => GENDERS.some((g) => g.value === v); + +/** A profile is one person, or (on couple sites) one account for two people. */ +export type ProfileKind = 'single' | 'couple'; +/** Couples grouped by who's in them, for seeking and Browse. Trans women count as women, trans men as men. */ +export type CoupleMix = 'mf' | 'ff' | 'mm' | 'other'; +export const COUPLE_MIXES: { value: CoupleMix; label: string; short: string }[] = [ + { value: 'mf', label: 'Couples (man + woman)', short: 'MF couple' }, + { value: 'ff', label: 'Couples (two women)', short: 'FF couple' }, + { value: 'mm', label: 'Couples (two men)', short: 'MM couple' }, + { value: 'other', label: 'Other couples', short: 'Couple' }, +]; +export const isCoupleMix = (v: unknown): v is CoupleMix => COUPLE_MIXES.some((c) => c.value === v); +/** The second person in a couple. The first person is the member's own gender, birth year and fields. */ +export interface Partner { + name?: string; // first name or nickname, optional + gender: Gender; + birthYear: number; + fields: Record; // answers to perPerson fields only +} +/** One person in a couple, as other members see them. */ +export interface PersonView { name?: string; gender: Gender; age: number; details: { key: string; label: string; value: string }[] } /** deleted: the member deleted their account (or their email hard-bounced). Hidden from everyone at once, * never emailed, kept for DELETED_RETENTION_DAYS so they can come back, then erased for good. */ export type MemberStatus = 'active' | 'suspended' | 'deleted'; @@ -214,7 +239,14 @@ export interface Member { profileComplete: boolean; birthYear: number; gender: Gender; + /** Single people they want to meet, by gender. On couple sites this can be empty if seekingCouples isn't. */ seeking: Gender[]; + /** Couple sites: missing means single. */ + kind?: ProfileKind; + /** Couple sites: the second person, when kind is 'couple'. */ + partner?: Partner; + /** Couple sites: which couples they want to meet. */ + seekingCouples?: CoupleMix[]; ageMin: number; ageMax: number; city: string; @@ -443,6 +475,8 @@ export interface MemberCard { likedByMe: boolean; isNew: boolean; // joined recently vip: boolean; // on the VIP tier: marked so they stand out in Browse + /** Set on couples: e.g. { mix: 'mf', ages: [38, 35] }. age is the first person's. */ + couple?: { mix: CoupleMix; genders: [Gender, Gender]; ages: [number, number] }; } export interface StrictPrefs { seeking: boolean; age: boolean; distance: boolean } @@ -466,6 +500,9 @@ export interface MemberProfile extends MemberCard { gender: Gender; /** Left out when the member keeps who they're looking for private. */ seeking?: Gender[]; + seekingCouples?: CoupleMix[]; + /** Couples: each partner's own details (height, body type...). Shared details stay in details. */ + people?: PersonView[]; /** Left out when the member keeps their age range private. */ ageMin?: number; ageMax?: number; @@ -592,12 +629,16 @@ export interface PublicSite { units: Units; /** Niche sites: Browse shows this checkbox to include members outside the niche. */ nicheIncludeLabel?: string; + /** Couple profiles are on: sign-up asks single or couple, Browse can filter couples. */ + couples: boolean; /** Present only when the owner turned Google tags on. restricted: sensitive site, no ad personalization or Google signals. */ googleTags?: { ga4Id?: string; adsId?: string; adsJoinLabel?: string; restricted: boolean }; } export interface SearchFilters { seeking?: Gender[]; + /** Couple sites: couples to include. Defaults to the member's own choice (with seeking). */ + seekingCouples?: CoupleMix[]; ageMin?: number; ageMax?: number; withinMiles?: number | null; diff --git a/packages/core/test/couples.test.ts b/packages/core/test/couples.test.ts new file mode 100644 index 0000000..d73648f --- /dev/null +++ b/packages/core/test/couples.test.ts @@ -0,0 +1,76 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { ApiError, coupleMix, createLocalMemberApi, createMemoryPlatform, seeks } from '../src/index'; + +async function join(mp: Awaited>, site: string, email: string, platform: 'web' | 'ios' = 'web') { + const m = createLocalMemberApi(mp.platform, site, platform); + const st = await m.startVerification('email', email); + m.setToken((await m.verify(st.challengeId, st.devCode!)).token); + return m; +} +const year = new Date().getUTCFullYear(); + +test('couple mixes group by who is in the couple', () => { + assert.equal(coupleMix('man', 'woman'), 'mf'); + assert.equal(coupleMix('woman', 'trans_mtf'), 'ff'); + assert.equal(coupleMix('man', 'man'), 'mm'); + assert.equal(coupleMix('nonbinary', 'woman'), 'other'); + const couple = { kind: 'couple' as const, gender: 'man' as const, partner: { gender: 'woman' as const, birthYear: 1990, fields: {} } }; + assert.ok(seeks({ seeking: ['woman'], seekingCouples: ['mf'] }, couple)); + assert.ok(!seeks({ seeking: ['woman', 'man'] }, couple), 'a couple only matches people who asked for couples'); + assert.ok(seeks({ seeking: ['man'] }, { gender: 'man' })); +}); + +test('a couple signs up with details for each partner, and singles find them in Browse', async () => { + const mp = await createMemoryPlatform(); + const site = await (await join(mp, 'swingandscore', 'probe@example.com')).site(); + assert.equal(site.couples, true); + assert.equal(site.mode, 'adult'); + + const c = await join(mp, 'swingandscore', 'couple@example.com'); + await assert.rejects(c.updateMe({ kind: 'couple', partner: { gender: 'woman', birthYear: year - 17 } }), (e: ApiError) => e.code === 'too_young'); + const me = await c.updateMe({ + displayName: 'SunAndMoon', birthYear: year - 40, gender: 'man', kind: 'couple', + partner: { name: 'Jo', gender: 'woman', birthYear: year - 36, fields: { height: 165, body_type: 'Curvy' } }, + seeking: ['woman'], seekingCouples: ['mf'], location: { country: 'US', postal: '80202' }, + fields: { height: 180, body_type: 'Athletic', experience: 'Some experience' }, + }); + assert.equal(me.member.profileComplete, true); + assert.equal(me.member.partner?.gender, 'woman'); + await assert.rejects(c.updateMe({ partner: { fields: { experience: 'Experienced' } } }), (e: ApiError) => e.code === 'bad_field', 'shared fields are not per person'); + + // A single woman looking for MF couples, aged 30-38: the couple fits because one partner is 36. + const w = await join(mp, 'swingandscore', 'single@example.com'); + await w.updateMe({ displayName: 'Skye', birthYear: year - 33, gender: 'woman', kind: 'single', seeking: [], seekingCouples: ['mf'], ageMin: 30, ageMax: 38, location: { country: 'US', postal: '80202' } }); + const found = await w.search({ withinMiles: 25 }); + const card = found.people.find((p) => p.displayName === 'SunAndMoon'); + assert.ok(card?.couple); + assert.deepEqual(card!.couple!.ages, [40, 36]); + assert.equal(card!.couple!.mix, 'mf'); + assert.ok(found.people.every((p) => p.couple), 'she asked for couples only'); + + // Per-person filters match either partner + assert.ok((await w.search({ withinMiles: 25, fields: { body_type: ['Curvy'] } })).people.some((p) => p.id === card!.id)); + assert.ok(!(await w.search({ withinMiles: 25, fields: { body_type: ['Slim', 'Large'] } })).people.some((p) => p.id === card!.id)); + + const prof = await w.profile(card!.id); + assert.equal(prof.people?.length, 2); + assert.equal(prof.people![1].name, 'Jo'); + assert.ok(prof.people![1].details.some((d) => d.label === 'Body type' && d.value === 'Curvy')); + assert.ok(prof.details.some((d) => d.label === 'Experience')); + assert.ok(!prof.details.some((d) => d.label === 'Body type'), 'per-person details sit with each partner'); + + // A couple looking for a third is fine here: no niche review on this site + await c.updateMe({ about: 'Fun MF couple looking for a third to join us for drinks and more.' }); +}); + +test('couple profiles stay off on other sites, and adult sites refuse the apps', async () => { + const mp = await createMemoryPlatform(); + const a = await join(mp, 'afterh', 'x@example.com'); + assert.equal((await a.site()).couples, false); + await assert.rejects(a.updateMe({ kind: 'couple' }), (e: ApiError) => e.code === 'no_couples'); + await assert.rejects(a.updateMe({ seeking: [] }), (e: ApiError) => e.code === 'bad_seeking'); + + const app = await join(mp, 'swingandscore', 'phone@example.com', 'ios'); + await assert.rejects(app.me(), (e: ApiError) => e.code === 'web_only'); +}); diff --git a/packages/core/test/dashboard.test.ts b/packages/core/test/dashboard.test.ts index 513159b..58cd7bd 100644 --- a/packages/core/test/dashboard.test.ts +++ b/packages/core/test/dashboard.test.ts @@ -86,7 +86,7 @@ test('dashboards respect site access: owners see only their sites', async () => assert.deepEqual(all.sites.map((s) => s.siteId), ['site_datealittle']); assert.equal(all.series.length, 30); const platform = await adminFor(mp, 'admin@whatbox.test'); - assert.equal((await platform.dashboardAll(7)).sites.length, 3); + assert.equal((await platform.dashboardAll(7)).sites.length, 4); // demo member sign-in shows up only on that site's numbers const m = createLocalMemberApi(mp.platform, 'afterh', 'web'); const st = await m.startVerification('email', DEMO_MEMBER_EMAIL); diff --git a/packages/core/test/platform.test.ts b/packages/core/test/platform.test.ts index 26682b2..bd4c9cf 100644 --- a/packages/core/test/platform.test.ts +++ b/packages/core/test/platform.test.ts @@ -214,7 +214,7 @@ test('owner admin: site switcher only lists managed sites; owners cannot change const st = await admin.start(DEMO_OWNER_EMAIL); admin.setToken((await admin.verify(st.challengeId, st.devCode!)).token); const me = await admin.me(); - assert.equal(me.sites.length, 3); + assert.equal(me.sites.length, 4); await assert.rejects(admin.updateSite('site_afterh', { settings: { mode: 'standard' } }), /Only WhatBox/); const site = await admin.updateSite('site_afterh', { settings: { membership: { tiers: { free: { seeWhoViewed: true } } } } }); assert.equal(site.settings.membership.tiers.free.seeWhoViewed, true); @@ -393,22 +393,22 @@ test('platform admin: create a site, assign an owner, suspend, usage and estimat const pa = await adminSignIn(mp, 'admin@whatbox.test'); await assert.rejects(pa.createSite({ slug: 'swing', name: 'Swing', domains: ['afterh.com'], mode: 'adult', ownerIds: [] }), (e: ApiError) => e.code === 'domain_taken'); const newOwner = await pa.saveOwner({ email: 'Pat@Example.com', name: 'Pat', siteIds: [] }); - const site = await pa.createSite({ slug: 'swingandscore', name: 'SwingAndScore', domains: ['https://www.SwingAndScore.com/'], mode: 'adult', ownerIds: [newOwner.id] }); - assert.deepEqual(site.domains, ['swingandscore.com']); + const site = await pa.createSite({ slug: 'swingermatch', name: 'SwingerMatch', domains: ['https://www.SwingerMatch.com/'], mode: 'adult', ownerIds: [newOwner.id] }); + assert.deepEqual(site.domains, ['swingermatch.com']); assert.equal(site.settings.membership.paywallEnabled, false); assert.equal(site.settings.explicitPhotosAllowed, false); assert.equal(site.settings.paymentProvider, 'none'); // The new owner sees only the new site const pat = await adminSignIn(mp, 'pat@example.com'); - assert.deepEqual((await pat.me()).sites.map((x) => x.slug), ['swingandscore']); + assert.deepEqual((await pat.me()).sites.map((x) => x.slug), ['swingermatch']); await assert.rejects(pat.updateSite(site.id, { settings: { paymentProvider: 'paypal' } }), (e: ApiError) => e.code === 'provider_not_allowed'); // Members can sign up on the new site, and its data is separate - const m = createLocalMemberApi(mp.platform, 'swingandscore.com', 'web'); + const m = createLocalMemberApi(mp.platform, 'swingermatch.com', 'web'); const st = await m.startVerification('email', 'new@example.com'); m.setToken((await m.verify(st.challengeId, st.devCode!)).token); - assert.equal((await m.site()).name, 'SwingAndScore'); + assert.equal((await m.site()).name, 'SwingerMatch'); // Suspend: members are turned away, admins still see it await pa.platformUpdateSite(site.id, { status: 'suspended' });