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
10 changes: 8 additions & 2 deletions .github/workflows/import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ on:
description: "AfterH only: current SkaDate .sql dump in the imports container (blank to skip)"
type: string
default: ''
dead_signups:
description: "Members who signed up on the old site but never used it (left within the hour, no messages, unverified...)"
type: choice
options: [flag, suspend, remove]
default: flag
skadate_photos:
description: "AfterH only: zip of SkaDate's ow_userfiles folder in the imports container (blank: no photos)"
type: string
Expand All @@ -63,6 +68,7 @@ jobs:
LEGACY: ${{ inputs.legacy_backup }}
SKADATE: ${{ inputs.skadate_dump }}
SKAPHOTOS: ${{ inputs.skadate_photos }}
DEAD: ${{ inputs.dead_signups }}
PREFIX: bundles/${{ inputs.site }}-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -154,8 +160,8 @@ jobs:
job="whatbox-$ENV-import"
report="reports/$SITE-${{ github.run_id }}.json"
case "$MODE" in
dry-run) args=(load --site "$SITE" --bundle "blob:$PREFIX" --dry-run --report-blob "$report") ;;
load) args=(load --site "$SITE" --bundle "blob:$PREFIX" --report-blob "$report") ;;
dry-run) args=(load --site "$SITE" --bundle "blob:$PREFIX" --dead-signups "$DEAD" --dry-run --report-blob "$report") ;;
load) args=(load --site "$SITE" --bundle "blob:$PREFIX" --dead-signups "$DEAD" --report-blob "$report") ;;
remove) args=(remove --site "$SITE" --report-blob "$report") ;;
risk-check) args=(risk-check --site "$SITE" --bundle "blob:$PREFIX" --report-blob "$report") ;;
esac
Expand Down
4 changes: 3 additions & 1 deletion apps/api/scripts/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ async function argsFromBlob(): Promise<string[]> {
};
try {
if (cmd === 'load' || cmd === 'risk-check') {
const deadSignups = (one(a, 'dead-signups', false) || 'flag') as 'flag' | 'suspend' | 'remove';
if (!['flag', 'suspend', 'remove'].includes(deadSignups)) throw new Error('--dead-signups must be flag, suspend or remove');
const given: string[] = [];
for (const b of a.bundle ?? []) {
if (!b.startsWith('blob:')) { given.push(b); continue; }
Expand All @@ -156,7 +158,7 @@ async function argsFromBlob(): Promise<string[]> {
for (const d of dirs) bundles.push(await readBundle(d));
const crypto = new SiteCrypto(keyProvider(), site.id);
if (cmd === 'risk-check') await output(await riskCheckImported(bundles, { site, repo, crypto, now: new Date(), dryRun }));
else await output(await loadBundles(bundles, { site, repo, crypto, geo: new WorldGeo(), photos, now: new Date(), dryRun }));
else await output(await loadBundles(bundles, { site, repo, crypto, geo: new WorldGeo(), photos, now: new Date(), dryRun, deadSignups }));
} else if (cmd === 'remove') {
await output(await removeImported(repo, site, photos, dryRun));
} else {
Expand Down
5 changes: 4 additions & 1 deletion apps/api/src/import/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface SrcMember {
key: string; // "<source>:<old id>", used only to connect relations inside one run
email: string;
username: string; // the public name members knew them by; real names are not carried over
/** The old site made the username up (SkaDate does, e.g. "h6jm"); the member never chose it. */
usernameGenerated?: boolean;
gender: SrcGender | null;
seeking: SrcGender[];
birthDate?: string; // YYYY-MM-DD
Expand All @@ -41,7 +43,8 @@ export interface SrcMember {
fields: Record<string, string | string[] | number>;
createdAt: string;
lastActiveAt: string;
/** Things a moderator should look at, e.g. "not_approved" or "spam_suspected" on the old site. */
/** Things a moderator should look at, e.g. "not_approved" or "spam_suspected" on the old site.
* "dead_signup": never really used the old site (left within the hour, no messages, unverified...). */
flags: string[];
photos: SrcPhoto[];
/** Countries and VPN/hosting networks the old site logged them signing in from. Derived; never the IPs. */
Expand Down
32 changes: 27 additions & 5 deletions apps/api/src/import/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ export function mergeMembers(bundles: Bundle[]): MergedMember[] {
if (m.ageMin === undefined) { m.ageMin = src.ageMin; m.ageMax = src.ageMax; }
if (!m.location.city && !m.location.lat && !m.location.postal) m.location = src.location;
if (!m.about) m.about = src.about;
if (!m.username) m.username = src.username;
// A name the member chose on one site beats one the other site made up.
if (!m.username || (m.usernameGenerated && src.username && !src.usernameGenerated)) {
m.username = src.username; m.usernameGenerated = src.usernameGenerated;
}
// Someone counts as a dead signup only if they never used ANY of the old sites.
const dead = m.flags.includes('dead_signup') && src.flags.includes('dead_signup');
m.createdAt = minIso(m.createdAt, src.createdAt);
m.lastActiveAt = maxIso(m.lastActiveAt, src.lastActiveAt);
m.flags = [...new Set([...m.flags, ...src.flags])];
m.flags = [...new Set([...m.flags, ...src.flags])].filter((f) => f !== 'dead_signup' || dead);
m.network = mergeNetworks(m.network, src.network);
cur.photos.push(...photos);
}
Expand Down Expand Up @@ -111,6 +116,8 @@ export interface LoadDeps {
photos?: PhotoStore; // without it, photos are counted but not copied
now: Date;
dryRun: boolean;
/** Signups that never used the old site: flag them for review (default), suspend them, or leave them out. */
deadSignups?: 'flag' | 'suspend' | 'remove';
}

export interface LoadReport {
Expand Down Expand Up @@ -159,6 +166,20 @@ export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise<LoadR
continue;
}
const src = g.m;
const dead = src.flags.includes('dead_signup');
if (dead) bump(report.members, 'never used the old site (signed up and left)');
if (dead && d.deadSignups === 'remove') {
for (const k of g.keys) idByKey.delete(k); // their likes and messages go too
if (existing && !d.dryRun) {
for (const p of await d.repo.listPhotos(existing.id)) if (p.blobKey) await d.photos?.delete(d.site, p.blobKey);
await d.repo.deleteMember(existing.id);
}
bump(report.members, existing ? 'removed (never used the old site)' : 'left out (never used the old site)');
continue;
}
// A made-up name is not shown: the member picks one at first sign-in.
const displayName = src.usernameGenerated ? '' : displayNameFrom(src.username);
if (!displayName) bump(report.members, 'old site made up their username (picks a name at first sign-in)');
const gender: Gender = src.gender && isGender(src.gender) ? src.gender : 'woman';
const place = await resolvePlace(d.geo, src.location);
if (!place) bump(report.members, 'no usable location (asked on first sign-in)');
Expand All @@ -176,12 +197,12 @@ export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise<LoadR
const member: Member = {
...(existing ?? {}),
id,
displayName: displayNameFrom(src.username),
displayName,
emailHash,
emailEnc: existing?.emailEnc ?? await d.crypto.encrypt(g.email),
verifiedAt: src.createdAt,
// Incomplete profiles go through profile setup when the member first signs in.
profileComplete: !!place && ageOk && !missingRequired && src.gender !== null,
profileComplete: !!displayName && !!place && ageOk && !missingRequired && src.gender !== null,
birthYear: ageOk ? birthYear : year - 30,
gender,
seeking: seekingFor(gender, src.seeking),
Expand All @@ -191,7 +212,7 @@ export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise<LoadR
units: existing?.units ?? (place ? unitsForCountry(place.country) : undefined),
about: src.about,
fields,
status: existing?.status ?? 'active',
status: dead && d.deadSignups === 'suspend' ? 'suspended' : existing?.status ?? 'active',
tier: existing?.tier ?? 'free',
hideExplicit: existing?.hideExplicit ?? true,
createdAt: src.createdAt,
Expand All @@ -204,6 +225,7 @@ export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise<LoadR

if (src.flags.includes('not_approved')) flagItem(id, id, 'profile', 'Imported member: was waiting for approval on the old site', 'not approved on the old site');
if (src.flags.includes('spam_suspected')) flagItem(id, id, 'profile', 'Imported member: flagged as possible spam on the old site', 'spam suspected on the old site');
if (dead && d.deadSignups !== 'suspend') flagItem(id, id, 'profile', 'Imported member: signed up on the old site but never used it (possible bot)', 'never used the old site');
if (src.flags.includes('suspended')) flagItem(id, id, 'profile', 'Imported member: was suspended on the old site', 'suspended on the old site');
if (member.about && findContactInfo(member.about).length) flagItem(id, id, 'profile', member.about.slice(0, 280), 'contact info in profile');
// Niche sites: answers that don't add up (e.g. "no dwarfism" at 3'4"), fetish or "third" wording. Review only.
Expand Down
7 changes: 7 additions & 0 deletions apps/api/src/import/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export function joinAbout(about: string[], meet: string | undefined, max = 2000)
}

/** Display names on the new platform: the old public username, tidied and capped. */
/** SkaDate makes up short names like "h6jm" or "9b5kcu0s" at signup. Real picks like "mike77" are kept. */
export function looksGenerated(username: string): boolean {
if (!/^[a-z0-9]{3,10}$/.test(username)) return false;
if (!/[aeiouy]/.test(username)) return true;
return /\d/.test(username.replace(/\d+$/, '')); // a digit somewhere other than the end
}

export function displayNameFrom(username: string): string {
const s = username.replace(/[_.]+/g, ' ').replace(/\s+/g, ' ').trim();
return (s || 'Member').slice(0, 30);
Expand Down
20 changes: 17 additions & 3 deletions apps/api/src/import/skadate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { networkFromHistory } from './network';
import { bump, type BundleInfo, type SrcMember, type SrcPhoto, type SrcRelation, photoPath, prepareBundleDir, writeBundle } from './bundle';
import { countBundle } from './legacy';
import {
cleanText, isoDate, joinAbout, skadateDrinking, skadateGenders, skadateGoal, skadateHeight, skadateInterests,
cleanText, isoDate, joinAbout, looksGenerated, skadateDrinking, skadateGenders, skadateGoal, skadateHeight, skadateInterests,
skadateSmoking, skadateStatus,
} from './map';

Expand Down Expand Up @@ -49,7 +49,7 @@ export async function extractSkadate(url: string, outDir: string, opts: { photos
const q = async <T = any>(text: string) => (await db.query(text))[0] as T[];
const info: BundleInfo = { source: 'skadate', site: 'afterh', extractedAt: new Date().toISOString(), counts: {}, skipped: {} };
try {
const users = await q(`SELECT id, email, username, joinStamp, activityStamp FROM ow_base_user ORDER BY id`);
const users = await q(`SELECT id, email, username, joinStamp, activityStamp, emailVerify FROM ow_base_user ORDER BY id`);
const data = new Map<number, Map<string, { t: string; i: number; d: Date | null }>>();
for (const r of await q(`SELECT userId, questionName, textValue, intValue, dateValue FROM ow_base_question_data`)) {
(data.get(r.userId) ?? data.set(r.userId, new Map()).get(r.userId)!).set(r.questionName, { t: r.textValue ?? '', i: Number(r.intValue ?? 0), d: r.dateValue });
Expand All @@ -58,6 +58,8 @@ export async function extractSkadate(url: string, outDir: string, opts: { photos
for (const r of await q(`SELECT entityId, countryCode, lat, lng, json FROM ow_googlelocation_data WHERE entityType='user'`)) locs.set(r.entityId, r);
const notApproved = new Set((await q(`SELECT userId FROM ow_base_user_disapprove`)).map((r) => r.userId));
const suspended = new Set((await q(`SELECT userId FROM ow_base_user_suspend`)).map((r) => r.userId));
const hasAvatar = new Set((await q(`SELECT userId FROM ow_base_avatar`)).map((r) => r.userId));
const wrote = new Set((await q(`SELECT DISTINCT senderId FROM ow_mailbox_message WHERE isSystem = 0`)).map((r) => r.senderId));

const members: SrcMember[] = [];
const keep = new Set<number>();
Expand Down Expand Up @@ -86,10 +88,22 @@ export async function extractSkadate(url: string, outDir: string, opts: { photos
const flags: string[] = [];
if (notApproved.has(u.id)) flags.push('not_approved');
if (suspended.has(u.id)) flags.push('suspended');
// Signups that never really used the site: three or more of these signs.
const signs = [
!Number(u.emailVerify),
Number(u.activityStamp) - Number(u.joinStamp) < 3600,
!wrote.has(u.id),
!hasAvatar.has(u.id),
notApproved.has(u.id),
d.size < 10,
].filter(Boolean).length;
if (signs >= 3) flags.push('dead_signup');
const username = String(u.username ?? '');
members.push({
key: 'skadate:' + u.id,
email,
username: String(u.username ?? ''),
username,
usernameGenerated: looksGenerated(username),
gender,
seeking: skadateGenders(d.get(Q.matchSex)?.i),
birthDate: birth && birth.getUTCFullYear() > 1900 ? isoDate(birth)!.slice(0, 10) : undefined,
Expand Down
38 changes: 37 additions & 1 deletion apps/api/test/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DevKeyProvider, MemorySiteRepo, SiteCrypto, seedSites } from '@whatbox/
import type { Bundle, SrcMember } from '../src/import/bundle';
import {
bits, cleanText, countryCode, joinAbout, legacyAccessibility, legacyGoal, legacyHeight, legacyKids, legacyStatus, legacyStature,
seekingFor, skadateGenders, skadateGoal, skadateHeight, skadateInterests, skadateStatus,
looksGenerated, seekingFor, skadateGenders, skadateGoal, skadateHeight, skadateInterests, skadateStatus,
} from '../src/import/map';
import { choosePhotos, keepFields, loadBundles, mergeMembers } from '../src/import/load';

Expand Down Expand Up @@ -106,3 +106,39 @@ test('loads into the named site only, and re-runs update instead of duplicating'
assert.notEqual(m.emailEnc, 'a@example.com');
assert.equal((await repo.listMessagesInvolving(m.id)).length, 1);
});

test('names SkaDate made up are not shown, and dead signups can be left out', async () => {
assert.equal(looksGenerated('h6jm'), true);
assert.equal(looksGenerated('hbkzl'), true);
assert.equal(looksGenerated('9b5kcu0s'), true);
assert.equal(looksGenerated('mike77'), false);
assert.equal(looksGenerated('sunny'), false);
assert.equal(looksGenerated('Sunny_Day'), false);

// A real name from the older site replaces the made-up one; dead only if dead everywhere.
const merged = mergeMembers([
bundle('skadate', [src({ key: 'skadate:3', username: 'x7kq2', usernameGenerated: true, flags: ['dead_signup'] })]),
bundle('aspnetdating', [src({ key: 'legacy:3', username: 'sunny' })]),
]);
assert.equal(merged[0].m.username, 'sunny');
assert.ok(!merged[0].m.flags.includes('dead_signup'));

const site = seedSites(new Date())[0];
const repo = new MemorySiteRepo();
const crypto = new SiteCrypto(new DevKeyProvider('test-only'), site.id);
const geo = { countries: async () => [], postal: async () => ({ id: 'z', name: 'Denver', region: 'CO', country: 'US', lat: 39.7, lng: -105, postal: '80202' }), search: async () => [], place: async () => null, nearest: async () => null };
const deps = { site, repo: repo as any, crypto, geo, now: new Date('2026-11-28T00:00:00Z'), dryRun: false };
const b = bundle('skadate', [
src({ key: 'skadate:1', username: 'h6jm', usernameGenerated: true, fields: { hsv_status: ['HSV-2'] } }),
src({ key: 'skadate:2', email: 'bot@example.com', username: 'q9zz', usernameGenerated: true, fields: { hsv_status: ['HSV-2'] }, flags: ['dead_signup'] }),
]);
await loadBundles([b], deps); // first run keeps both (flagged)
const bot = await repo.findMemberByHash('email', await crypto.lookupHash('bot@example.com'));
assert.ok(bot);
const r = await loadBundles([b], { ...deps, deadSignups: 'remove' as const });
assert.equal(r.members['removed (never used the old site)'], 1);
assert.equal(await repo.findMemberByHash('email', await crypto.lookupHash('bot@example.com')), null);
const real = await repo.findMemberByHash('email', await crypto.lookupHash('a@example.com'));
assert.equal(real?.displayName, '');
assert.equal(real?.profileComplete, false); // picks a name at first sign-in
});
6 changes: 3 additions & 3 deletions apps/member/src/app/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ function Members({ api, siteId }: { api: AdminApi; siteId: string }) {
<Card pad={0} style={{ overflow: 'hidden' }}>
{data.rows.map((m, idx) => (
<View key={m.id} style={{ flexDirection: 'row', alignItems: 'center', gap: 12, padding: 14, borderTopWidth: idx ? 1 : 0, borderColor: t.line, flexWrap: 'wrap' }}>
<Pressable style={{ flex: 1, minWidth: 180 }} onPress={() => setOpenId(m.id)} accessibilityRole="button" accessibilityLabel={`View ${m.displayName}'s profile`}>
<Pressable style={{ flex: 1, minWidth: 180 }} onPress={() => setOpenId(m.id)} accessibilityRole="button" accessibilityLabel={`View ${m.displayName || 'this member'}'s profile`}>
<View style={{ flexDirection: 'row', gap: 8, alignItems: 'center' }}>
<Txt bold color={t.accent}>{m.displayName}{m.age ? `, ${m.age}` : ''}</Txt>
<Txt bold color={t.accent}>{m.displayName || 'No name yet'}{m.age ? `, ${m.age}` : ''}</Txt>
{m.tier !== 'free' ? <Badge label={m.tier === 'vip' ? '★ VIP' : 'Paid'} tone={m.tier === 'vip' ? 'alert' : 'accent'} /> : null}
{m.status === 'suspended' ? <Badge label="Suspended" tone="alert" /> : null}
{m.reports ? <Badge label={`${m.reports} report${m.reports > 1 ? 's' : ''}`} tone="alert" /> : null}
Expand Down Expand Up @@ -573,7 +573,7 @@ function MemberProfilePanel({ api, siteId, memberId, onClose }: { api: AdminApi;
<View style={{ flex: 1, backgroundColor: 'rgba(10,14,13,0.55)', alignItems: 'center', justifyContent: 'center', padding: wide ? 32 : 0 }}>
<View style={{ backgroundColor: t.surface, borderRadius: wide ? 18 : 0, width: '100%', maxWidth: 820, maxHeight: '100%', flex: wide ? undefined : 1, overflow: 'hidden' }}>
<View style={{ flexDirection: 'row', alignItems: 'center', padding: 16, borderBottomWidth: 1, borderColor: t.line, gap: 10 }}>
<H size={20} level={2} style={{ flex: 1 }}>{p ? `${p.displayName}${p.age ? `, ${p.age}` : ''}` : 'Profile'}</H>
<H size={20} level={2} style={{ flex: 1 }}>{p ? `${p.displayName || 'No name yet'}${p.age ? `, ${p.age}` : ''}` : 'Profile'}</H>
<Pressable onPress={onClose} accessibilityRole="button" accessibilityLabel="Close profile" style={{ width: 40, height: 40, alignItems: 'center', justifyContent: 'center' }}>
<Icon name="x" />
</Pressable>
Expand Down
Loading
Loading