From 9798b7c6fbeb823311f0975edbcb7f3f97095b24 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 03:03:08 +0000 Subject: [PATCH 1/2] SwingAndScore: couple profiles and the new adult site - Couple profiles (per-site setting): one account for two people in any combination, each with their own age, gender and per-person fields; seeking covers couples by mix and singles by gender; a couple matches an age range or field filter when either partner does - Both partners must be 18+; adult sites refuse the iOS/Android apps - SwingAndScore added as a built-in site (adult mode, couples on, photos reviewed first, no public teasers, no payment provider yet), with lifestyle fields and safe-for-work starter pages and guides - Bootstrap adds starter pages for new sites; deploy creates its key - Cleared profile answers are dropped instead of rejected Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvSVsBpLUiWJrs1S248 --- .github/workflows/deploy.yml | 2 +- apps/api/scripts/bootstrap.ts | 13 +- apps/member/src/app/(app)/activity.tsx | 6 +- apps/member/src/app/(app)/browse.tsx | 10 +- apps/member/src/app/(app)/discover.tsx | 4 +- apps/member/src/app/(app)/me.tsx | 22 ++- apps/member/src/app/(app)/member/[id].tsx | 19 +- apps/member/src/app/(app)/messages/[id].tsx | 4 +- apps/member/src/app/(app)/messages/index.tsx | 4 +- apps/member/src/app/onboarding.tsx | 43 +++-- apps/member/src/ui/CoupleEditor.tsx | 80 ++++++++ apps/member/src/ui/PrototypeBar.tsx | 1 + packages/core/src/couples.ts | 71 ++++++++ packages/core/src/index.ts | 1 + packages/core/src/seed.ts | 34 +++- packages/core/src/services.ts | 129 ++++++++++--- packages/core/src/starter-content.ts | 181 ++++++++++++++++++- packages/core/src/types.ts | 41 +++++ packages/core/test/couples.test.ts | 76 ++++++++ packages/core/test/dashboard.test.ts | 2 +- packages/core/test/platform.test.ts | 12 +- 21 files changed, 681 insertions(+), 74 deletions(-) create mode 100644 apps/member/src/ui/CoupleEditor.tsx create mode 100644 packages/core/src/couples.ts create mode 100644 packages/core/test/couples.test.ts 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/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 0706b6b..37a49cc 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 29585c5..2535ff5 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'; @@ -39,7 +39,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[]; @@ -109,7 +110,7 @@ export default function ProfileScreen() { - {p.displayName}, {p.age} + {p.displayName}, {agesLabel(p)} {p.tier === 'vip' ? : null} {p.verified ? ( @@ -118,6 +119,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' : ''} @@ -178,6 +180,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 cbda087..4610e6d 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'; @@ -45,7 +45,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/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 dfc9911..e545361 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 9fa6480..951ef8c 100644 --- a/packages/core/src/services.ts +++ b/packages/core/src/services.ts @@ -5,12 +5,13 @@ 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, Notifier, PaymentGateway, PhotoStore, SiteProvisioner, SiteRepo } from './repo'; import { systemClock } from './repo'; -import { DEFAULT_LICENSING, DEFAULT_NOTIFY, DEFAULT_STRICT, isGender, type HiddenPrefs, type NotifyPrefs, type StrictPrefs } from './types'; +import { DEFAULT_LICENSING, 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, @@ -72,6 +73,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[]; } export interface AccessRow { member: MemberCard; status: AccessStatus; updatedAt: string } @@ -136,6 +143,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), }; } @@ -335,6 +343,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)); @@ -409,6 +419,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], + } } : {}), }; }); } @@ -467,10 +481,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]; @@ -508,6 +523,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; } @@ -517,7 +533,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); @@ -529,6 +547,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]; @@ -694,15 +758,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) { @@ -710,11 +778,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); @@ -760,7 +824,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); @@ -779,7 +859,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) } : {}), @@ -980,26 +1061,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); } @@ -1089,10 +1169,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 a38d814..f12c31b 100644 --- a/packages/core/src/starter-content.ts +++ b/packages/core/src/starter-content.ts @@ -402,6 +402,185 @@ 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'), + }, + { + slug: 'swinging-for-beginners', kind: 'article', category: 'Getting started', title: 'Swinging for beginners: a guide for curious couples', placement: 'guides', + 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.', + 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.', + '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.', + ].join('\n\n'), + }, + { + slug: 'swinger-etiquette', kind: 'article', category: 'Etiquette', title: 'Swinger etiquette: the unwritten rules', placement: 'guides', + 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.', + 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, including halfway through an evening.', + 'Be honest in your profile. Current photos, real ages, and a clear picture of what you are into. Surprises are rarely good ones.', + 'The first meeting is just a drink. No expectations, no pressure. If the chemistry is not there, that is completely normal.', + '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, and you can expect the same.', + ].join('\n\n'), + }, + { + slug: 'soft-swap-vs-full-swap', kind: 'article', category: 'Getting started', title: 'Soft swap vs full swap: what the terms mean', placement: 'guides', + 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.', + 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 means partners are open to sex with others.', + 'Same room and separate room describe whether couples stay together or are fine being apart.', + 'Friends first means 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.', + ].join('\n\n'), + }, + { + slug: 'couples-finding-a-third', kind: 'article', category: 'Relationships', title: 'How couples find a third, respectfully', placement: 'guides', + 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.', + 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.', + ].join('\n\n'), + }, + { + slug: 'lifestyle-clubs-and-parties', kind: 'article', category: 'Events', title: 'Lifestyle clubs and parties: what to expect', placement: 'guides', + summary: 'Dress codes, house rules, and why your first visit can be just a drink.', + seoTitle: 'Swinger clubs and lifestyle parties: what to expect on your first visit', + 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.', + 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, and what happens where. Read them before you go.', + 'There is no pressure. Plenty of people go just to dance, have a drink and people-watch. That is a perfectly good first visit.', + '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.', + ].join('\n\n'), + }, + { + slug: 'safer-sex-in-the-lifestyle', kind: 'article', category: 'Safety', title: 'Safer sex in the lifestyle', placement: 'guides', + 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.', + 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, which makes the conversation easy.', + 'Respect a no. If someone wants protection or wants to wait, that is the end of the discussion.', + 'Ask your doctor or a local sexual health clinic for advice that fits you. This guide is general information, not medical advice.', + ].join('\n\n'), + }, + scamGuide(n), + ]; +} + // ---------- Any other site: neutral starting text ---------- function generic(site: Site): Draft[] { @@ -428,7 +607,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 15450ff..6750ba9 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -75,6 +75,8 @@ export interface SiteSettings { googleTags?: GoogleTags; /** 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 { @@ -134,6 +136,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 { @@ -194,6 +198,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 }[] } export type MemberStatus = 'active' | 'suspended'; export interface Member { @@ -207,7 +232,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; @@ -413,6 +445,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 } @@ -436,6 +470,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; @@ -562,12 +599,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 a458e21..faff9b1 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); @@ -388,22 +388,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' }); From 21f4ca0873afef5639b37662b9dc144897e012d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 03:07:20 +0000 Subject: [PATCH 2/2] Smoke test: the demo owner now manages four sites (SwingAndScore added) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvSVsBpLUiWJrs1S248 --- apps/api/scripts/smoke.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } });