Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class PublicController extends SiteScoped {
@Get('site/pages/:slug') async page(@Req() r: Request, @Param('slug') slug: string) {
return (await this.p.publicPage(await this.site(r), slug)) ?? null;
}
// Public "Report content" form: anyone can ask for content to be removed.
@Post('site/takedown') async takedown(@Req() r: Request, @Body() b: any) {
return this.p.submitTakedown(await this.site(r), { name: b?.name, contact: b?.contact, where: b?.where, details: b?.details, aboutMe: b?.aboutMe === true }, { ip: r.ip });
}
@Post('auth/start') async start(@Req() r: Request, @Body() b: { channel: 'email' | 'phone'; target: string }) {
return this.p.startVerification(await this.site(r), b.channel, String(b.target ?? ''), { ip: r.ip });
}
Expand Down Expand Up @@ -109,18 +113,18 @@ export class MeController extends SiteScoped {
@Patch() async update(@Req() r: Request, @Body() b: any) { return this.p.updateProfile(await this.ctx(r), b); }
@Post('photos') async addPhoto(@Req() r: Request, @Body() b: any) {
// JSON route: placeholder tones (tests) or data URIs when PHOTO_STORE=inline. Real files use /photos/upload.
return this.p.addPhoto(await this.ctx(r), { kind: b.kind, rating: b.rating, url: b.url, tone: b.tone });
return this.p.addPhoto(await this.ctx(r), { kind: b.kind, rating: b.rating, url: b.url, tone: b.tone, consent: b.consent === true });
}
@Post('photos/upload')
@UseInterceptors(FileInterceptor('file', { limits: { fileSize: 10 * 1024 * 1024, files: 1 } }))
async uploadPhoto(@Req() r: Request, @UploadedFile() file: { buffer: Buffer } | undefined, @Body() b: { kind?: string; rating?: string }) {
async uploadPhoto(@Req() r: Request, @UploadedFile() file: { buffer: Buffer } | undefined, @Body() b: { kind?: string; rating?: string; consent?: string }) {
const ctx = await this.ctx(r);
if (!file?.buffer?.length) throw new RuleError('no_file', 'Choose a photo to upload.');
const img = await normalizeImage(file.buffer);
return this.p.addPhoto(ctx, { kind: b.kind as PhotoKind, rating: b.rating as PhotoRating, file: img });
return this.p.addPhoto(ctx, { kind: b.kind as PhotoKind, rating: b.rating as PhotoRating, file: img, consent: b.consent === 'true' });
}
@Patch('photos/:id') async updPhoto(@Req() r: Request, @Param('id') id: string, @Body() b: any) {
return this.p.updatePhoto(await this.ctx(r), id, { kind: b.kind, rating: b.rating });
return this.p.updatePhoto(await this.ctx(r), id, { kind: b.kind, rating: b.rating, consent: b.consent === true });
}
@Delete('photos/:id') async delPhoto(@Req() r: Request, @Param('id') id: string) { return this.p.deletePhoto(await this.ctx(r), id); }
@Post('push') async push(@Req() r: Request, @Body() b: { token?: string; platform?: string }) {
Expand Down
2 changes: 2 additions & 0 deletions apps/member/src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
import { SessionProvider, useSession } from '../lib/session';
import { PrototypeBar } from '../ui/PrototypeBar';
import { UpdateBanner } from '../ui/UpdateBanner';
import { AgeGate } from '../ui/AgeGate';

function WebHead() {
const { site } = useSession();
Expand Down Expand Up @@ -36,6 +37,7 @@ function Shell() {
<PrototypeBar />
<UpdateBanner />
<Stack screenOptions={{ headerShown: false, contentStyle: { backgroundColor: site.theme.ground } }} />
<AgeGate />
</View>
);
}
Expand Down
19 changes: 18 additions & 1 deletion apps/member/src/app/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ function Moderation({ api, siteId, niche, onChange }: { api: AdminApi; siteId: s
risk: ['Possible scammer', 'Looks fine', 'Suspend member'],
member: ['Account review', 'Looks fine', 'Suspend account'],
email: ['Lost access to email', 'Move account to the new email', 'Decline'],
takedown: ['Removal request', 'Done: content removed', 'No action needed'],
};
const runNiche = async () => {
setNicheRun({ busy: true });
Expand Down Expand Up @@ -322,7 +323,7 @@ function Moderation({ api, siteId, niche, onChange }: { api: AdminApi; siteId: s
</Pressable>
) : (
<View style={{ width: 52, height: 52, borderRadius: 26, backgroundColor: i.kind === 'message' ? '#FFF4E5' : t.accentSoft, alignItems: 'center', justifyContent: 'center' }}>
<Icon name={i.kind === 'message' ? 'chat' : i.kind === 'report' || i.kind === 'member' ? 'flag' : i.kind === 'risk' ? 'globe' : i.kind === 'email' ? 'send' : 'user'} color={i.kind === 'message' ? '#8A5A12' : t.accent} />
<Icon name={i.kind === 'message' ? 'chat' : i.kind === 'report' || i.kind === 'member' ? 'flag' : i.kind === 'risk' ? 'globe' : i.kind === 'email' ? 'send' : i.kind === 'takedown' ? 'flag' : 'user'} color={i.kind === 'message' ? '#8A5A12' : t.accent} />
</View>
)}
<View style={{ flex: 1, minWidth: 240, gap: 6 }}>
Expand All @@ -348,6 +349,22 @@ function Moderation({ api, siteId, niche, onChange }: { api: AdminApi; siteId: s
</View>
) : null}
</>
) : i.kind === 'takedown' && i.takedown ? (
<>
{/* From the public "Report content" form. Find the content (See profile on the member, or Members search), remove it, then mark done. */}
<View style={{ backgroundColor: t.ground, borderRadius: 10, padding: 12, gap: 6 }}>
<Txt size={15}>{i.takedown.details}</Txt>
{i.takedown.where ? <Txt sub size={14}>Where: {i.takedown.where}</Txt> : null}
<Txt sub size={14}>{i.takedown.aboutMe ? 'They say they are pictured in it.' : 'Reported on behalf of someone else.'} Reply to: {i.takedownContact}</Txt>
</View>
<Txt sub size={13}>Remove the content while you look into it. Anything showing someone under 18 must also be reported to the authorities (in the US, the NCMEC CyberTipline).</Txt>
{i.status === 'pending' ? (
<View style={{ flexDirection: 'row', gap: 8, marginTop: 6, flexWrap: 'wrap' }}>
<Btn size="sm" label={labels.takedown[1]} onPress={() => decide(i.id, 'approve')} />
<Btn size="sm" label={labels.takedown[2]} kind="secondary" onPress={() => decide(i.id, 'reject')} />
</View>
) : null}
</>
) : (
<>
{i.kind !== 'member' ? <Txt size={15}>{i.summary}</Txt> : null}
Expand Down
45 changes: 45 additions & 0 deletions apps/member/src/ui/AgeGate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Adult sites only: "Adults only" notice before anyone signed out can use the member app. The public
// site sets a cookie on the parent domain when a visitor answers there, so they aren't asked twice.
// Signed-in members already confirmed they are 18+ when they joined.
import { useEffect, useState } from 'react';
import { Linking, Platform, View } from 'react-native';
import { useSession } from '../lib/session';
import { storage } from '../lib/storage';
import { Btn, H, Txt, useTheme } from './kit';

const KEY = 'whatbox.adult-ok';
const COOKIE = 'wb_adult_ok';

function cookieSaysOk() {
return Platform.OS === 'web' && typeof document !== 'undefined' && document.cookie.split('; ').some((c) => c === `${COOKIE}=1`);
}

export function AgeGate() {
const { site, signedIn } = useSession();
const t = useTheme();
const [ok, setOk] = useState<boolean | null>(null);
useEffect(() => {
if (site.mode !== 'adult' || signedIn || cookieSaysOk()) { setOk(true); return; }
storage.get(`${KEY}.${site.slug}`).then((v) => setOk(v === '1')).catch(() => setOk(false));
}, [site, signedIn]);
if (ok !== false) return null;
const accept = () => {
storage.set(`${KEY}.${site.slug}`, '1').catch(() => {});
setOk(true);
};
return (
<View role="dialog" aria-modal aria-label="Adults only" style={{ position: Platform.OS === 'web' ? ('fixed' as any) : 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 100, backgroundColor: 'rgba(20,12,20,0.94)', alignItems: 'center', justifyContent: 'center', padding: 16 }}>
<View style={{ backgroundColor: t.surface, borderRadius: 20, padding: 28, maxWidth: 460, width: '100%', gap: 12, alignItems: 'center' }}>
<View style={{ backgroundColor: t.accent, borderRadius: 999, paddingHorizontal: 14, paddingVertical: 6 }}><Txt bold color="#FFFFFF">18+</Txt></View>
<H size={30} level={1}>Adults only</H>
<Txt sub style={{ textAlign: 'center' }}>
{site.name} is a community for adults. Members may share adult content. You must be 18 or older, and old enough to view adult content where you live, to continue.
</Txt>
<View style={{ gap: 10, alignSelf: 'stretch', marginTop: 8 }}>
<Btn label="I am 18 or older. Enter" size="lg" onPress={accept} />
<Btn label="Leave" kind="secondary" onPress={() => Linking.openURL('https://www.google.com')} />
</View>
</View>
</View>
);
}
24 changes: 19 additions & 5 deletions apps/member/src/ui/PhotoManager.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// Main photo + up to 6 public + up to 6 private, with the site's explicit-photo rules.
import { ApiError, TONES, type MyProfile, type PhotoKind, type PhotoRating, type PhotoView } from '@whatbox/core';
import { ApiError, PHOTO_CONSENT_STATEMENT, TONES, type MyProfile, type PhotoKind, type PhotoRating, type PhotoView } from '@whatbox/core';
import * as ImagePicker from 'expo-image-picker';
import { useState } from 'react';
import { Platform, Pressable, View } from 'react-native';
import { IS_PREVIEW } from '../lib/backend';
import { useSession } from '../lib/session';
import { Badge, Btn, Chip, ErrorText, H, Icon, PhotoTile, Txt, useTheme } from './kit';
import { Badge, Btn, Check, Chip, ErrorText, H, Icon, PhotoTile, Txt, useTheme } from './kit';

export function PhotoManager({ only }: { only?: PhotoKind[] }) {
const { api, me, setMe, site } = useSession();
const t = useTheme();
const [selected, setSelected] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
// Adult sites: the uploader confirms age and consent for everyone in each photo (kept as a record).
const adult = site.mode === 'adult';
const [confirmed, setConfirmed] = useState(false);
const consent = adult ? { consent: true } : {};
if (!me) return null;
const photos = me.photos;
const main = photos.find((p) => p.kind === 'main');
Expand All @@ -27,16 +31,17 @@ export function PhotoManager({ only }: { only?: PhotoKind[] }) {
}

async function add(kind: PhotoKind, source: 'device' | 'sample') {
if (adult && !confirmed) { setError('First tick the box to confirm everyone in your photos is 18 or older and agreed to them being posted.'); return; }
if (source === 'sample') {
const tone = TONES[Math.floor(Math.random() * TONES.length)];
return run(() => api.addPhoto({ kind, tone }));
return run(() => api.addPhoto({ kind, tone, ...consent }));
}
const res = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ['images'], quality: IS_PREVIEW ? 0.5 : 0.9, base64: IS_PREVIEW, allowsEditing: true, aspect: [1, 1] });
if (res.canceled || !res.assets?.[0]) return;
const a = res.assets[0];
// The preview keeps a data URI in the browser; the real app uploads the file itself.
const url = IS_PREVIEW && a.base64 ? `data:${a.mimeType ?? 'image/jpeg'};base64,${a.base64}` : a.uri;
return run(() => api.addPhoto({ kind, url }));
return run(() => api.addPhoto({ kind, url, ...consent }));
}

const slot = (p: PhotoView | undefined, kind: PhotoKind, i: number) => {
Expand Down Expand Up @@ -107,6 +112,12 @@ export function PhotoManager({ only }: { only?: PhotoKind[] }) {
</View>
</View>
) : null}
{adult ? (
<View style={{ gap: 4 }}>
<Check label={PHOTO_CONSENT_STATEMENT} value={confirmed} onChange={setConfirmed} />
<Txt sub size={12}>We keep a record of this for each photo you add. Every photo is reviewed before other members see it.</Txt>
</View>
) : null}
{show('public') ? section('Public photos', 'public', pub, 'Any signed-in member can see these.') : null}
{show('private') ? section('Private photos', 'private', priv, `Members have to ask. You approve each request and can revoke it any time.${site.explicitPhotosAllowed ? ' Explicit photos are allowed here, shown on the website only.' : ''}`) : null}

Expand All @@ -124,7 +135,10 @@ export function PhotoManager({ only }: { only?: PhotoKind[] }) {
<Txt size={13} bold>Content rating</Txt>
<View style={{ flexDirection: 'row', gap: 8, flexWrap: 'wrap' }}>
{(['safe', 'suggestive', 'explicit'] as PhotoRating[]).map((r) => (
<Chip key={r} label={r[0].toUpperCase() + r.slice(1)} selected={sel.rating === r} onPress={() => run(() => api.updatePhoto(sel.id, { rating: r }))} />
<Chip key={r} label={r[0].toUpperCase() + r.slice(1)} selected={sel.rating === r} onPress={() => {
if (adult && r === 'explicit' && !confirmed) { setError('First tick the box to confirm everyone in this photo is 18 or older and agreed to it being posted.'); return; }
run(() => api.updatePhoto(sel.id, { rating: r, ...consent }));
}} />
))}
</View>
{!site.explicitPhotosAllowed ? <Txt sub size={12}>{site.name} does not allow explicit photos.</Txt> : null}
Expand Down
45 changes: 45 additions & 0 deletions apps/web/app/AgeGate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use client';
// Adult sites only: a full-screen "18 or older?" notice on the first visit, remembered for a year in a
// first-party cookie. The page underneath is still in the HTML, so search engines can read it (it is
// safe for work by design); the notice only stops a visitor from using the site until they answer.
import { useEffect, useRef, useState } from 'react';

const COOKIE = 'wb_adult_ok';

export function AgeGate({ name }: { name: string }) {
const [open, setOpen] = useState(false);
const enter = useRef<HTMLButtonElement>(null);
useEffect(() => {
if (!document.cookie.split('; ').some((c) => c === `${COOKIE}=1`)) setOpen(true);
}, []);
useEffect(() => {
if (!open) return;
enter.current?.focus();
document.body.style.overflow = 'hidden';
return () => { document.body.style.overflow = ''; };
}, [open]);
if (!open) return null;
const accept = () => {
// On the real domain the cookie covers app.<domain> too, so the member app doesn't ask again.
const host = location.hostname.replace(/^www\./, '');
const domain = host.includes('.') && !host.endsWith('.azurecontainerapps.io') && !/^[\d.]+$/.test(host) ? `; Domain=${host}` : '';
document.cookie = `${COOKIE}=1; Max-Age=${365 * 86400}; Path=/; SameSite=Lax; Secure${domain}`;
setOpen(false);
};
return (
<div className="age-gate" role="dialog" aria-modal="true" aria-labelledby="age-gate-title" aria-describedby="age-gate-text">
<div className="age-gate-card">
<p className="age-gate-badge">18+</p>
<h2 id="age-gate-title">Adults only</h2>
<p id="age-gate-text">
{name} is a community for adults in the swinger lifestyle. Members may share adult content behind sign-in.
You must be 18 or older, and old enough to view adult content where you live, to continue.
</p>
<div className="age-gate-actions">
<button ref={enter} className="btn primary" onClick={accept}>I am 18 or older. Enter</button>
<a className="btn secondary" href="https://www.google.com" rel="noopener noreferrer">Leave</a>
</div>
</div>
</div>
);
}
15 changes: 15 additions & 0 deletions apps/web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,18 @@ summary{font-weight:700;cursor:pointer}
.update-banner button{min-height:36px;padding:0 14px;border-radius:min(var(--radius),18px);font:700 14px var(--body),system-ui,sans-serif;cursor:pointer}
.update-reload{background:var(--accent);color:#fff;border:1.5px solid var(--accent)}
.update-later{background:transparent;color:var(--ink);border:1.5px solid var(--line)}
/* Adult sites: 18+ notice on the first visit */
.age-gate{position:fixed;inset:0;z-index:100;background:rgba(20,12,20,.92);backdrop-filter:blur(14px);display:flex;align-items:center;justify-content:center;padding:16px}
.age-gate-card{background:var(--surface);color:var(--ink);max-width:460px;width:100%;border-radius:20px;padding:28px 24px;text-align:center;box-shadow:0 20px 60px rgba(0,0,0,.4)}
.age-gate-card h2{font-family:var(--heading),serif;font-size:30px;margin:6px 0 10px}
.age-gate-card p{color:var(--sub);line-height:1.55}
.age-gate-badge{display:inline-block;margin:0;padding:6px 14px;border-radius:999px;background:var(--accent);color:#fff !important;font-weight:800;letter-spacing:.04em}
.age-gate-actions{display:flex;flex-direction:column;gap:10px;margin-top:20px}
/* Report content form */
.form{display:flex;flex-direction:column;gap:16px;max-width:560px;margin:24px 0}
.form label{display:flex;flex-direction:column;gap:6px;font-weight:600}
.form label.check{flex-direction:row;align-items:center;gap:10px;font-weight:500}
.form input:not([type=checkbox]),.form textarea{font:inherit;padding:12px 14px;border:1.5px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink)}
.form input[type=checkbox]{width:20px;height:20px}
.form .error{color:#9A2E3A;margin:0}
.notice{background:var(--accentSoft);border-radius:12px;padding:16px;margin:24px 0}
15 changes: 13 additions & 2 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { articleCategories, landingStyle } from '@whatbox/core';
import { appUrl, getPages, getSite } from '../lib/site';
import { Measure } from './measure';
import { UpdateBanner } from './UpdateBanner';
import { AgeGate } from './AgeGate';
import './globals.css';

export async function generateMetadata(): Promise<Metadata> {
Expand Down Expand Up @@ -42,10 +43,15 @@ export default async function RootLayout({ children }: { children: ReactNode })
const topics = articleCategories(pages);
return (
<html lang="en">
<head>{t.fontsHref ? <link rel="stylesheet" href={t.fontsHref} /> : null}</head>
<head>
{t.fontsHref ? <link rel="stylesheet" href={t.fontsHref} /> : null}
{/* "Restricted to Adults" label: lets parental-control software and filters recognise the site. */}
{site.mode === 'adult' ? <meta name="rating" content="RTA-5042-1996-1400-1577-RTA" /> : null}
</head>
<body style={vars} className={`style-${style}`}>
<a className="skip" href="#main">Skip to main content</a>
<UpdateBanner />
{site.mode === 'adult' ? <AgeGate name={site.name} /> : null}
<header className="top">
<div className="wrap">
<Logo name={site.name} accent={t.accent} second={t.second} />
Expand All @@ -68,7 +74,12 @@ export default async function RootLayout({ children }: { children: ReactNode })
{topics.map((c) => <a key={c.slug} href={`/guides/${c.slug}`}>{c.name}</a>)}
</nav>
) : null}
{footer.length ? <nav aria-label="Footer">{footer.map((p) => <a key={p.slug} href={`/${p.slug}`}>{p.title}</a>)}</nav> : null}
{footer.length || site.mode === 'adult' ? (
<nav aria-label="Footer">
{footer.map((p) => <a key={p.slug} href={`/${p.slug}`}>{p.title}</a>)}
{site.mode === 'adult' ? <a href="/report-content">Report content</a> : null}
</nav>
) : null}
<small>© {new Date().getFullYear()} WhatBox, LLC</small>
</div>
</footer>
Expand Down
Loading
Loading