From 13a6e45ef633b0c4d2fc7e99f89d232071911c7f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 19:25:33 +0000 Subject: [PATCH 1/4] Import members from the old sites (AfterH, HFriends, DateALittle) Extractors for the old AspNetDating sites (SQL Server) and the current AfterH SkaDate site (MySQL) write a bundle; the loader writes one site's database with that site's own key and photo container, refusing bundles for any other site. AfterH members found in both systems merge by email (SkaDate answers win). Re-runs update instead of duplicating; members who already joined or have signed in since keep their profile. Members sign in with an emailed code, so no password migration or reset is needed. Azure: private "imports" container, import job, and an "Import members" workflow (dry-run / load / remove). Mapping and steps in infra/import-members.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvNyMo8QQFmyaDpp8vc --- .github/workflows/import.yml | 181 +++++++++ apps/api/package.json | 6 +- apps/api/scripts/import.ts | 158 ++++++++ apps/api/src/import/bundle.ts | 86 +++++ apps/api/src/import/legacy.ts | 147 ++++++++ apps/api/src/import/load.ts | 287 +++++++++++++++ apps/api/src/import/map.ts | 181 +++++++++ apps/api/src/import/skadate.ts | 173 +++++++++ apps/api/test/import.test.ts | 102 ++++++ infra/README.md | 1 + infra/import-members.md | 112 ++++++ infra/main.bicep | 42 +++ package-lock.json | 649 ++++++++++++++++++++++++++++++++- packages/core/src/types.ts | 2 + 14 files changed, 2123 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/import.yml create mode 100644 apps/api/scripts/import.ts create mode 100644 apps/api/src/import/bundle.ts create mode 100644 apps/api/src/import/legacy.ts create mode 100644 apps/api/src/import/load.ts create mode 100644 apps/api/src/import/map.ts create mode 100644 apps/api/src/import/skadate.ts create mode 100644 apps/api/test/import.test.ts create mode 100644 infra/import-members.md diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml new file mode 100644 index 0000000..5d15ddb --- /dev/null +++ b/.github/workflows/import.yml @@ -0,0 +1,181 @@ +name: Import members + +# Run by hand from the Actions tab. Brings members from an old site into ONE new site. +# Before the first run, upload the backups to the private "imports" container of the +# environment's storage account (steps in infra/import-members.md). +# +# dry-run restore, extract and check everything; nothing is written to the site +# load the real import (safe to repeat: it updates rather than duplicates) +# remove take every imported member off the site again (demo data and new sign-ups stay) +# +# Real member data goes to prod. Use dev for test runs. +on: + workflow_dispatch: + inputs: + environment: + description: Environment + type: choice + options: [dev, prod] + default: dev + site: + description: Site + type: choice + options: [afterh, hfriends, datealittle] + default: afterh + mode: + description: What to do + type: choice + options: [dry-run, load, remove] + default: dry-run + legacy_backup: + description: Old site SQL Server backup in the imports container (blank to skip) + type: string + default: '' + skadate_dump: + description: "AfterH only: current SkaDate .sql dump in the imports container (blank to skip)" + type: string + default: '' + skadate_photos: + description: "AfterH only: zip of SkaDate's ow_userfiles folder in the imports container (blank: no photos)" + type: string + default: '' + +permissions: + id-token: write + contents: read + +concurrency: + group: import-${{ inputs.environment }} + cancel-in-progress: false + +jobs: + import: + runs-on: ubuntu-latest + timeout-minutes: 90 + environment: ${{ inputs.environment }} + env: + ENV: ${{ inputs.environment }} + RG: ${{ vars.AZURE_RESOURCE_GROUP }} + SITE: ${{ inputs.site }} + MODE: ${{ inputs.mode }} + LEGACY: ${{ inputs.legacy_backup }} + SKADATE: ${{ inputs.skadate_dump }} + SKAPHOTOS: ${{ inputs.skadate_photos }} + WORK: ${{ runner.temp }}/import + PREFIX: bundles/${{ inputs.site }}-${{ github.run_id }} + steps: + - uses: actions/checkout@v4 + + - name: Check inputs + run: | + if [ "$MODE" != remove ] && [ -z "$LEGACY$SKADATE" ]; then echo "Give a legacy backup and/or a SkaDate dump."; exit 1; fi + if [ -n "$SKADATE$SKAPHOTOS" ] && [ "$SITE" != afterh ]; then echo "SkaDate files belong to AfterH only."; exit 1; fi + + - uses: azure/login@v2 + with: + client-id: ${{ vars.AZURE_CLIENT_ID }} + tenant-id: ${{ vars.AZURE_TENANT_ID }} + subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} + + - name: Storage account + id: st + run: | + acct=$(az resource list -g "$RG" --resource-type Microsoft.Storage/storageAccounts --query "[0].name" -o tsv) + key=$(az storage account keys list -g "$RG" -n "$acct" --query "[0].value" -o tsv) + echo "::add-mask::$key" + echo "acct=$acct" >> "$GITHUB_OUTPUT" + echo "AZURE_STORAGE_ACCOUNT=$acct" >> "$GITHUB_ENV" + echo "AZURE_STORAGE_KEY=$key" >> "$GITHUB_ENV" + + - uses: actions/setup-node@v4 + if: ${{ inputs.mode != 'remove' }} + with: + node-version: 22 + cache: npm + - if: ${{ inputs.mode != 'remove' }} + run: npm ci + + # The old databases are restored only inside this runner, which is thrown away afterwards. + - name: Restore the old site backup (SQL Server) + if: ${{ inputs.mode != 'remove' && inputs.legacy_backup != '' }} + run: | + mkdir -p "$WORK/bak" && chmod 777 "$WORK/bak" + az storage blob download --auth-mode key -c imports -n "$LEGACY" -f "$WORK/bak/legacy.bak" -o none + chmod 644 "$WORK/bak/legacy.bak" + SA_PW="Wb$(openssl rand -hex 16)!"; echo "::add-mask::$SA_PW"; echo "SA_PW=$SA_PW" >> "$GITHUB_ENV" + docker run -d --name mssql -e ACCEPT_EULA=Y -e "MSSQL_SA_PASSWORD=$SA_PW" -p 127.0.0.1:1433:1433 -v "$WORK/bak:/bak" mcr.microsoft.com/mssql/server:2022-latest + sq() { docker exec mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "$SA_PW" -b -h -1 -W -s '|' -Q "SET NOCOUNT ON; $1"; } + for i in $(seq 1 60); do sq "SELECT 1" >/dev/null 2>&1 && break; sleep 3; done + files=$(sq "RESTORE FILELISTONLY FROM DISK='/bak/legacy.bak'" | cut -d'|' -f1,3) + data=$(grep '|D$' <<<"$files" | head -1 | cut -d'|' -f1); log=$(grep '|L$' <<<"$files" | head -1 | cut -d'|' -f1) + sq "RESTORE DATABASE legacy FROM DISK='/bak/legacy.bak' WITH MOVE '$data' TO '/var/opt/mssql/data/legacy.mdf', MOVE '$log' TO '/var/opt/mssql/data/legacy.ldf'" + + - name: Extract the old site + if: ${{ inputs.mode != 'remove' && inputs.legacy_backup != '' }} + run: npm run import -w @whatbox/api -- extract-legacy --site "$SITE" --out "$WORK/bundles/2-legacy" | tee -a "$WORK/extract.txt" + env: + SOURCE_MSSQL: Server=localhost,1433;Database=legacy;User Id=sa;Password=${{ env.SA_PW }};Encrypt=true;TrustServerCertificate=true + + - name: Restore the SkaDate dump (MariaDB) + if: ${{ inputs.mode != 'remove' && inputs.skadate_dump != '' }} + run: | + mkdir -p "$WORK" + az storage blob download --auth-mode key -c imports -n "$SKADATE" -f "$WORK/skadate.sql" -o none + MY_PW=$(openssl rand -hex 16); echo "::add-mask::$MY_PW"; echo "MY_PW=$MY_PW" >> "$GITHUB_ENV" + docker run -d --name maria -e "MARIADB_ROOT_PASSWORD=$MY_PW" -e MARIADB_DATABASE=skadate -p 127.0.0.1:3306:3306 mariadb:10.6 + for i in $(seq 1 60); do docker exec maria mariadb -uroot "-p$MY_PW" -e "SELECT 1" >/dev/null 2>&1 && break; sleep 3; done + docker exec -i maria mariadb -uroot "-p$MY_PW" skadate < "$WORK/skadate.sql" + if [ -n "$SKAPHOTOS" ]; then + az storage blob download --auth-mode key -c imports -n "$SKAPHOTOS" -f "$WORK/userfiles.zip" -o none + mkdir -p "$WORK/userfiles" && unzip -q "$WORK/userfiles.zip" -d "$WORK/userfiles" + fi + + - name: Extract SkaDate + if: ${{ inputs.mode != 'remove' && inputs.skadate_dump != '' }} + run: | + photos=(); [ -d "$WORK/userfiles" ] && photos=(--photos "$WORK/userfiles") + npm run import -w @whatbox/api -- extract-skadate --out "$WORK/bundles/1-skadate" "${photos[@]}" | tee -a "$WORK/extract.txt" + env: + SOURCE_MYSQL: mysql://root:${{ env.MY_PW }}@127.0.0.1:3306/skadate + + # The newer system (1-skadate) wins for profile answers; the older one fills the gaps. + - name: Hand the bundles to Azure + if: ${{ inputs.mode != 'remove' }} + run: az storage blob upload-batch --auth-mode key -d imports --destination-path "$PREFIX" -s "$WORK/bundles" -o none --only-show-errors + + - name: Run the import job + run: | + set -o pipefail + az extension add --name containerapp --upgrade --only-show-errors + 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") ;; + remove) args=(remove --site "$SITE" --report-blob "$report") ;; + esac + # The job reads (and deletes) this file, so its own settings and secrets stay untouched. + printf '%s\n' "${args[@]}" | jq -R . | jq -sc '{args: .}' > "$RUNNER_TEMP/next.json" + az storage blob upload --auth-mode key -c imports -n jobs/next.json -f "$RUNNER_TEMP/next.json" --overwrite -o none + exec=$(az containerapp job start -g "$RG" -n "$job" --query name -o tsv) + for i in $(seq 1 360); do + status=$(az containerapp job execution show -g "$RG" -n "$job" --job-execution-name "$exec" --query properties.status -o tsv) + echo "import: $status" + [ "$status" = "Succeeded" ] && break + [ "$status" = "Failed" ] && { echo "The import job failed. Its log is in the container app job's execution history."; exit 1; } + sleep 10 + done + [ "$status" = "Succeeded" ] || exit 1 + az storage blob download --auth-mode key -c imports -n "$report" -f "$RUNNER_TEMP/report.json" -o none + { + echo "### $MODE: $SITE on $ENV" + echo '```json'; cat "$RUNNER_TEMP/report.json"; echo '```' + if [ -f "$WORK/extract.txt" ]; then echo "#### What the extract left behind"; echo '```'; cat "$WORK/extract.txt"; echo '```'; fi + } >> "$GITHUB_STEP_SUMMARY" + + # The bundles hold member data in plain text. Only the original backups stay in the container. + - name: Remove the bundles + if: always() + run: | + az storage blob delete-batch --auth-mode key -s imports --pattern "$PREFIX/*" -o none --only-show-errors || true + rm -rf "$WORK" diff --git a/apps/api/package.json b/apps/api/package.json index 5395f7d..0bfb222 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -10,10 +10,12 @@ "test": "node --import tsx --test test/*.test.ts", "smoke": "tsx scripts/smoke.ts", "cleanup": "tsx scripts/cleanup.ts", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "import": "tsx scripts/import.ts" }, "devDependencies": { "@types/express": "^5.0.6", + "@types/mssql": "^12.3.2", "@types/node": "^26.6.11", "@types/pg": "^8.23.1", "typescript": "~6.0.3" @@ -28,6 +30,8 @@ "@whatbox/core": "^0.1.0", "all-the-cities": "3.1.0", "jose": "^6.2.18", + "mssql": "^12.8.3", + "mysql2": "^3.24.6", "pg": "^8.23.1", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.2", diff --git a/apps/api/scripts/import.ts b/apps/api/scripts/import.ts new file mode 100644 index 0000000..296858a --- /dev/null +++ b/apps/api/scripts/import.ts @@ -0,0 +1,158 @@ +// Member import from the old sites. Two steps, so the old databases never need to be reachable +// from Azure and the new database never needs to be reachable from wherever the backups are restored: +// +// extract reads a restored backup and writes a bundle folder (see src/import/bundle.ts) +// npm run import -w @whatbox/api -- extract-legacy --site afterh --out (SOURCE_MSSQL=) +// npm run import -w @whatbox/api -- extract-skadate --out [--photos ] (SOURCE_MYSQL=mysql://...) +// +// load writes bundles into ONE site's database (first bundle wins for profile answers) +// npm run import -w @whatbox/api -- load --site afterh --bundle --bundle [--dry-run] +// +// remove deletes every imported member on a site (not demo data, not real sign-ups) +// npm run import -w @whatbox/api -- remove --site afterh [--dry-run] +// +// In Azure (the "Import members" workflow), --bundle blob: reads bundles from the private +// "imports" container, and --report-blob writes the counts back there for the workflow summary. +// +// Output is counts only. Member details never go to the console or logs. +import { SiteCrypto } from '@whatbox/core'; +import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob'; +import { mkdir, mkdtemp, readdir, rm } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { dirname, join } from 'node:path'; +import { config } from '../src/config'; +import { closePools, keyProvider, pool } from '../src/db'; +import { WorldGeo } from '../src/geo'; +import { PgControlRepo, PgSiteRepo, siteDbName } from '../src/pg-repo'; +import { createPhotoStore } from '../src/photos'; +import { readBundle } from '../src/import/bundle'; +import { extractLegacy, LEGACY_SITES, type LegacySite } from '../src/import/legacy'; +import { loadBundles, removeImported } from '../src/import/load'; +import { extractSkadate } from '../src/import/skadate'; + +function args(argv: string[]) { + const out: Record = {}; + for (let i = 0; i < argv.length; i++) { + const a = argv[i]; + if (!a.startsWith('--')) continue; + const k = a.slice(2); + const v = argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[++i] : 'true'; + (out[k] ??= []).push(v); + } + return out; +} +const one = (a: Record, k: string, required = true) => { + const v = a[k]?.[0]; + if (!v && required) throw new Error(`--${k} is required`); + return v ?? ''; +}; + +const IMPORTS_CONTAINER = 'imports'; +function importsContainer() { + if (!config.azureStorageAccount || !config.azureStorageKey) throw new Error('blob: bundles need AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY.'); + const cred = new StorageSharedKeyCredential(config.azureStorageAccount, config.azureStorageKey); + return new BlobServiceClient(`https://${config.azureStorageAccount}.blob.core.windows.net`, cred).getContainerClient(IMPORTS_CONTAINER); +} + +/** Copies blob: bundles from the imports container into a private temporary folder. */ +async function fetchBlobBundles(prefix: string, into: string) { + const cont = importsContainer(); + const clean = prefix.replace(/^\/+|\/+$/g, '') + '/'; + let n = 0; + for await (const b of cont.listBlobsFlat({ prefix: clean })) { + const rel = b.name.slice(clean.length); + if (!rel || rel.includes('..')) continue; + const dest = join(into, rel); + await mkdir(dirname(dest), { recursive: true, mode: 0o700 }); + await cont.getBlobClient(b.name).downloadToFile(dest); + n++; + } + if (!n) throw new Error(`Nothing found under ${IMPORTS_CONTAINER}/${clean}`); + return into; +} + +/** A --bundle folder may hold one bundle, or several (one per sub-folder, loaded in name order). */ +async function bundleDirs(dirs: string[]) { + const out: string[] = []; + for (const d of dirs) { + const entries = await readdir(d, { withFileTypes: true }); + if (entries.some((e) => e.name === 'info.json')) out.push(d); + else out.push(...entries.filter((e) => e.isDirectory()).map((e) => join(d, e.name)).sort()); + } + return out; +} + +/** The Azure job is started with no arguments of its own; it reads them from imports/jobs/next.json. */ +async function argsFromBlob(): Promise { + const blob = importsContainer().getBlockBlobClient('jobs/next.json'); + const task = JSON.parse((await blob.downloadToBuffer()).toString('utf8')) as { args: string[] }; + await blob.delete(); // single use + if (!Array.isArray(task.args) || !['load', 'remove'].includes(task.args[0])) throw new Error('jobs/next.json must hold {"args": ["load" | "remove", ...]}'); + return task.args.map(String); +} + +(async () => { + let argv = process.argv.slice(2); + if (argv[0] === 'from-blob') argv = await argsFromBlob(); + const [cmd, ...rest] = argv; + const a = args(rest); + const dryRun = a['dry-run']?.[0] === 'true'; + + if (cmd === 'extract-legacy') { + const site = one(a, 'site') as LegacySite; + if (!LEGACY_SITES.includes(site)) throw new Error(`--site must be one of ${LEGACY_SITES.join(', ')}`); + const conn = process.env.SOURCE_MSSQL; + if (!conn) throw new Error('Set SOURCE_MSSQL to the restored database connection string.'); + const info = await extractLegacy(site, conn, one(a, 'out')); + console.log(JSON.stringify({ source: info.source, site: info.site, counts: info.counts, skipped: info.skipped }, null, 2)); + return; + } + if (cmd === 'extract-skadate') { + const url = process.env.SOURCE_MYSQL; + if (!url) throw new Error('Set SOURCE_MYSQL to mysql://user:pass@host:3306/database'); + const info = await extractSkadate(url, one(a, 'out'), { photosDir: one(a, 'photos', false) || undefined }); + console.log(JSON.stringify({ source: info.source, site: info.site, counts: info.counts, skipped: info.skipped }, null, 2)); + return; + } + + const slug = one(a, 'site'); + const control = new PgControlRepo(pool(config.controlDb)); + const site = await control.findSite(slug); + if (!site) throw new Error(`No site "${slug}" in the control database. Run migrations first.`); + const repo = new PgSiteRepo(pool(siteDbName(site.slug))); + const photos = createPhotoStore(); + + let tmp: string | undefined; + const output = async (result: unknown) => { + const text = JSON.stringify(result, null, 2); + console.log(text); + const name = one(a, 'report-blob', false); + if (name) await importsContainer().getBlockBlobClient(name).upload(text, Buffer.byteLength(text), { blobHTTPHeaders: { blobContentType: 'application/json' } }); + }; + try { + if (cmd === 'load') { + const given: string[] = []; + for (const b of a.bundle ?? []) { + if (!b.startsWith('blob:')) { given.push(b); continue; } + tmp ??= await mkdtemp(join(tmpdir(), 'wbx-import-')); + given.push(await fetchBlobBundles(b.slice(5), join(tmp, String(given.length)))); + } + const dirs = await bundleDirs(given); + if (!dirs.length) throw new Error('Give at least one --bundle folder.'); + const bundles = []; + for (const d of dirs) bundles.push(await readBundle(d)); + const report = await loadBundles(bundles, { + site, repo, crypto: new SiteCrypto(keyProvider(), site.id), geo: new WorldGeo(), photos, now: new Date(), dryRun, + }); + await output(report); + } else if (cmd === 'remove') { + await output(await removeImported(repo, site, photos, dryRun)); + } else { + throw new Error('Usage: import extract-legacy | extract-skadate | load | remove (see the top of scripts/import.ts)'); + } + } finally { + if (tmp) await rm(tmp, { recursive: true, force: true }); // the downloaded bundle holds member data + } +})() + .then(() => closePools()) + .catch(async (e) => { console.error(e instanceof Error ? e.message : e); await closePools().catch(() => {}); process.exit(1); }); diff --git a/apps/api/src/import/bundle.ts b/apps/api/src/import/bundle.ts new file mode 100644 index 0000000..2f430cf --- /dev/null +++ b/apps/api/src/import/bundle.ts @@ -0,0 +1,86 @@ +// The hand-off format between an extractor (reads an old site's database) and the loader +// (writes one site's database on the new platform). A bundle is a folder: +// +// info.json where it came from and counts, no member data +// members.ndjson one SrcMember per line +// relations.ndjson likes, favorites, blocks, views, private photo access, messages +// photos/.jpg photo files, already re-encoded (metadata stripped) +// +// A bundle holds member email addresses and messages in plain text, like the backup it came from. +// Keep it only in the private "imports" storage container or a temporary folder, never in git. +import { mkdir, readFile, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import type { Gender, PhotoKind } from '@whatbox/core'; + +export type SourceKind = 'aspnetdating' | 'skadate'; +export type SrcGender = Gender | 'couple'; + +export interface SrcPhoto { + file: string; // name inside photos/ + kind: PhotoKind; + approved: boolean; + explicit: boolean; + createdAt: string; +} + +/** As the old site had it. The loader turns it into a town on the new platform, never an address. */ +export interface SrcLocation { country?: string; region?: string; city?: string; postal?: string; lat?: number; lng?: number } + +export interface SrcMember { + key: string; // ":", 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 + gender: SrcGender | null; + seeking: SrcGender[]; + birthDate?: string; // YYYY-MM-DD + ageMin?: number; + ageMax?: number; + location: SrcLocation; + about: string; + fields: Record; + createdAt: string; + lastActiveAt: string; + /** Things a moderator should look at, e.g. "not_approved" or "spam_suspected" on the old site. */ + flags: string[]; + photos: SrcPhoto[]; +} + +export type SrcRelation = + | { type: 'like' | 'favorite' | 'block' | 'view' | 'access'; from: string; to: string; at: string } + | { type: 'message'; id: string; from: string; to: string; at: string; body: string; read: boolean }; + +export interface BundleInfo { + source: SourceKind; + /** The one site this bundle may be loaded into. The loader refuses any other. */ + site: string; + extractedAt: string; + counts: Record; + /** Left behind on purpose, by reason (deleted accounts, couples, photos over the limit...). */ + skipped: Record; +} + +export interface Bundle { dir: string; info: BundleInfo; members: SrcMember[]; relations: SrcRelation[] } + +export function bump(rec: Record, key: string, by = 1) { rec[key] = (rec[key] ?? 0) + by; } + +export async function prepareBundleDir(dir: string) { await mkdir(join(dir, 'photos'), { recursive: true, mode: 0o700 }); } + +export async function writeBundle(dir: string, info: BundleInfo, members: SrcMember[], relations: SrcRelation[]) { + await prepareBundleDir(dir); + const nd = (rows: unknown[]) => rows.map((r) => JSON.stringify(r)).join('\n') + (rows.length ? '\n' : ''); + await writeFile(join(dir, 'members.ndjson'), nd(members), { mode: 0o600 }); + await writeFile(join(dir, 'relations.ndjson'), nd(relations), { mode: 0o600 }); + await writeFile(join(dir, 'info.json'), JSON.stringify(info, null, 2) + '\n', { mode: 0o600 }); +} + +export async function readBundle(dir: string): Promise { + const lines = async (f: string) => (await readFile(join(dir, f), 'utf8')).split('\n').filter(Boolean).map((l) => JSON.parse(l)); + return { + dir, + info: JSON.parse(await readFile(join(dir, 'info.json'), 'utf8')), + members: await lines('members.ndjson'), + relations: await lines('relations.ndjson'), + }; +} + +export const photoPath = (b: { dir: string }, file: string) => join(b.dir, 'photos', file); diff --git a/apps/api/src/import/legacy.ts b/apps/api/src/import/legacy.ts new file mode 100644 index 0000000..d35ac50 --- /dev/null +++ b/apps/api/src/import/legacy.ts @@ -0,0 +1,147 @@ +// Extractor for the old AspNetDating sites (old AfterH, HFriends, DateALittle: one schema). +// Reads a restored SQL Server copy of the backup and writes a bundle. Never writes to the source. +// +// Not carried over: passwords (the new platform signs in with an emailed code), real names, +// IP addresses, billing details, chat rooms, blogs, ratings, deleted accounts and couple profiles. +import sql from 'mssql'; +import { writeFile } from 'node:fs/promises'; +import { normalizeImage } from '../photos'; +import { bump, type BundleInfo, type SrcMember, type SrcPhoto, type SrcRelation, photoPath, prepareBundleDir, writeBundle } from './bundle'; +import { + cleanText, countryCode, isoDate, joinAbout, legacyDrinking, legacyGender, legacyGoal, legacyHeight, legacyKids, + legacySmoking, legacyStatus, legacyAccessibility, legacyStature, +} from './map'; + +// ProfileQuestions ids, the same on all three sites. Question 20 (and 21 on HFriends) is each site's own. +const Q = { height: 1, lookingFor: 4, smoking: 7, drinking: 8, about: 10, meet: 11, haveKids: 17, wantKids: 18, q20: 20, q21: 21 }; +export type LegacySite = 'afterh' | 'hfriends' | 'datealittle'; +export const LEGACY_SITES: LegacySite[] = ['afterh', 'hfriends', 'datealittle']; +const DELETED_FOLDER = 2147483647; +const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + +export async function extractLegacy(site: LegacySite, connectionString: string, outDir: string, opts: { photos?: boolean } = {}) { + if (!LEGACY_SITES.includes(site)) throw new Error('Unknown legacy site ' + site); + await prepareBundleDir(outDir); + const pool = await new sql.ConnectionPool(connectionString).connect(); + const q = async (text: string) => (await pool.request().query(text)).recordset as T[]; + const info: BundleInfo = { source: 'aspnetdating', site, extractedAt: new Date().toISOString(), counts: {}, skipped: {} }; + try { + const users = await q(`SELECT u_username, u_email, u_gender, u_interested_in, u_birthdate, u_usersince, u_lastonline, u_lastlogin, + u_country, u_state, u_city, u_zip_code, u_latitude, u_longitude, u_deleted, u_spamsuspected FROM Users`); + const answers = new Map>(); + for (const a of await q(`SELECT u_username, pq_id, pa_value FROM ProfileAnswers`)) { + const k = String(a.u_username).toLowerCase(); + (answers.get(k) ?? answers.set(k, new Map()).get(k)!).set(a.pq_id, a.pa_value); + } + const ages = new Map(); + for (const s of await q(`SELECT u_username, ss_agefrom, ss_ageto FROM SavedSearches WHERE ss_agefrom > 0 AND ss_ageto > 0 ORDER BY ss_id`)) { + ages.set(String(s.u_username).toLowerCase(), { from: s.ss_agefrom, to: s.ss_ageto }); + } + + const members: SrcMember[] = []; + const keep = new Set(); + const seenEmail = new Set(); + for (const u of users) { + const uname = String(u.u_username); + const email = String(u.u_email ?? '').trim().toLowerCase(); + if (u.u_deleted) { bump(info.skipped, 'deleted account'); continue; } + const gender = legacyGender(u.u_gender); + if (gender === 'couple') { bump(info.skipped, 'couple profile (not supported yet)'); continue; } + if (!gender) { bump(info.skipped, 'no gender'); continue; } + if (!EMAIL_RE.test(email)) { bump(info.skipped, 'no usable email'); continue; } + if (seenEmail.has(email)) { bump(info.skipped, 'second account with the same email'); continue; } + seenEmail.add(email); + const a = answers.get(uname.toLowerCase()) ?? new Map(); + const fields: SrcMember['fields'] = {}; + const set = (k: string, v: string | string[] | number | undefined) => { if (v !== undefined) fields[k] = v; }; + if (site === 'afterh') set('hsv_status', legacyStatus(a.get(Q.q20))); + if (site === 'hfriends') set('accessibility', legacyAccessibility(a.get(Q.q20), a.get(Q.q21))); + if (site === 'datealittle') set('stature', legacyStature(a.get(Q.q20))); + set('relationship_goal', legacyGoal(a.get(Q.lookingFor))); + set('height', legacyHeight(a.get(Q.height))); + set('kids', legacyKids(a.get(Q.haveKids), a.get(Q.wantKids))); + set('smoking', legacySmoking(a.get(Q.smoking))); + set('drinking', legacyDrinking(a.get(Q.drinking))); + const range = ages.get(uname.toLowerCase()); + const birth = isoDate(u.u_birthdate); + members.push({ + key: 'legacy:' + uname.toLowerCase(), + email, + username: uname, + gender, + seeking: [legacyGender(u.u_interested_in)].filter((g): g is NonNullable => !!g), + birthDate: birth?.slice(0, 10), + ageMin: range?.from, ageMax: range?.to, + location: { + country: countryCode(u.u_country), region: cleanText(u.u_state) || undefined, city: cleanText(u.u_city) || undefined, + postal: String(u.u_zip_code ?? '').trim() || undefined, + lat: u.u_latitude || undefined, lng: u.u_longitude || undefined, + }, + about: joinAbout([a.get(Q.about) ?? ''], a.get(Q.meet)), + fields, + createdAt: isoDate(u.u_usersince) ?? new Date(0).toISOString(), + lastActiveAt: isoDate(u.u_lastonline) ?? isoDate(u.u_lastlogin) ?? isoDate(u.u_usersince)!, + flags: u.u_spamsuspected ? ['spam_suspected'] : [], + photos: [], + }); + keep.add(uname.toLowerCase()); + } + const byKey = new Map(members.map((m) => [m.key, m])); + const key = (u: string) => 'legacy:' + String(u).toLowerCase(); + + // Photos are stored inside the database. Main first, then in upload order. + const albums = new Map((await q(`SELECT pa_id, pa_access FROM PhotoAlbums`)).map((r) => [r.pa_id, r.pa_access])); + const photoRows = await q(`SELECT p_id, u_username, pa_id, p_approved, p_primary, p_explicit, p_private, p_approvedtimestamp FROM Photos ORDER BY u_username, p_primary DESC, p_id`); + for (const p of photoRows) { + const m = byKey.get(key(p.u_username)); + if (!m) { bump(info.skipped, 'photo of a member not imported'); continue; } + const isPrivate = !!p.p_private || (p.pa_id && (albums.get(p.pa_id) ?? 0) !== 0); + const hasMain = m.photos.some((x) => x.kind === 'main'); + const kind: SrcPhoto['kind'] = isPrivate || p.p_explicit ? 'private' : !hasMain ? 'main' : 'public'; + const count = m.photos.filter((x) => x.kind === kind).length; + if (kind !== 'main' && count >= 6) { bump(info.skipped, `${kind} photo over the limit of 6`); continue; } + if (opts.photos !== false) { + const row = (await pool.request().input('id', sql.Int, p.p_id).query('SELECT p_image FROM Photos WHERE p_id=@id')).recordset[0]; + try { + const { data } = await normalizeImage(row.p_image); + const file = `legacy-${p.p_id}.jpg`; + await writeFile(photoPath({ dir: outDir }, file), data, { mode: 0o600 }); + m.photos.push({ file, kind, approved: !!p.p_approved, explicit: !!p.p_explicit, createdAt: isoDate(p.p_approvedtimestamp) ?? m.createdAt }); + } catch { bump(info.skipped, 'photo file unreadable'); } + } + } + + const relations: SrcRelation[] = []; + const rel = (type: 'like' | 'favorite' | 'block' | 'view' | 'access', from: string, to: string, at: unknown) => { + if (keep.has(String(from).toLowerCase()) && keep.has(String(to).toLowerCase()) && String(from).toLowerCase() !== String(to).toLowerCase()) { + relations.push({ type, from: key(from), to: key(to), at: isoDate(at as Date) ?? info.extractedAt }); + } else bump(info.skipped, `${type} with a member not imported`); + }; + for (const r of await q(`SELECT i_from_username f, i_to_username t, i_date_posted at FROM Interests`)) rel('like', r.f, r.t, r.at); + for (const r of await q(`SELECT u_username f, f_username t, f_timestamp at FROM Favourites`)) rel('favorite', r.f, r.t, r.at); + for (const r of await q(`SELECT bu_userblocker f, bu_blockeduser t, bu_blockdate at FROM BlockedUsers`)) rel('block', r.f, r.t, r.at); + for (const r of await q(`SELECT pv_viewer f, pv_viewed t, pv_timestamp at FROM ProfileViews`)) rel('view', r.f, r.t, r.at); + for (const r of await q(`SELECT pa_photoowner f, pa_photoviewer t, pa_dateaccessgranted at FROM PhotoAccess`)) rel('access', r.f, r.t, r.at); + for (const r of await q(`SELECT m_id, m_from_username f, m_to_username t, m_body, m_timestamp, m_is_read, m_pending_approval, m_from_folder, m_to_folder FROM Messages ORDER BY m_id`)) { + if (r.m_pending_approval) { bump(info.skipped, 'message never delivered (pending approval)'); continue; } + if (r.m_from_folder === DELETED_FOLDER && r.m_to_folder === DELETED_FOLDER) { bump(info.skipped, 'message deleted by both people'); continue; } + const body = cleanText(r.m_body); + if (!body) { bump(info.skipped, 'empty message'); continue; } + if (!keep.has(String(r.f).toLowerCase()) || !keep.has(String(r.t).toLowerCase())) { bump(info.skipped, 'message with a member not imported'); continue; } + relations.push({ type: 'message', id: 'legacy-' + r.m_id, from: key(r.f), to: key(r.t), at: isoDate(r.m_timestamp)!, body, read: !!r.m_is_read }); + } + + info.counts = countBundle(members, relations); + await writeBundle(outDir, info, members, relations); + return info; + } finally { + await pool.close(); + } +} + +export function countBundle(members: SrcMember[], relations: SrcRelation[]) { + const c: Record = { members: members.length, photos: members.reduce((n, m) => n + m.photos.length, 0) }; + const plural: Record = { access: 'private photo access', like: 'likes', favorite: 'favorites', block: 'blocks', view: 'views', message: 'messages' }; + for (const r of relations) bump(c, plural[r.type]); + return c; +} diff --git a/apps/api/src/import/load.ts b/apps/api/src/import/load.ts new file mode 100644 index 0000000..601bb3c --- /dev/null +++ b/apps/api/src/import/load.ts @@ -0,0 +1,287 @@ +// Loads one or more bundles into ONE site's database, with that site's own key and photo container. +// +// - Members found in more than one bundle (same email) become one member. The first bundle +// given wins for profile answers; the others fill gaps. Joined = earliest, last active = latest. +// - Safe to run again: ids come from a keyed hash of the email, so a re-run updates the same +// records instead of adding copies. A member who has signed in on the new site since the last +// run keeps what they changed (only new relations are added). +// - Someone who already joined the new site with the same email is never overwritten: their old +// likes, messages and so on are attached to their new account, nothing else. +// - Nothing about members is logged: the report has counts only. +import { createHash } from 'node:crypto'; +import { readFile } from 'node:fs/promises'; +import { + findContactInfo, type Gender, type GeoPlace, type GeoProvider, isGender, type Member, type ModerationItem, type Photo, type PhotoKind, + type PhotoStore, type ProfileFieldDef, type Site, type SiteCrypto, type SiteRepo, PHOTO_LIMITS, unitsForCountry, +} from '@whatbox/core'; +import { type Bundle, bump, photoPath, type SrcLocation, type SrcMember, type SrcPhoto } from './bundle'; +import { displayNameFrom, seekingFor } from './map'; + +export const IMPORT_ID_PREFIX = 'm_imp_'; + +export interface MergedMember { + email: string; + sources: string[]; // bundle sources, in priority order + keys: string[]; // every source key that points at this person + m: SrcMember; // merged view + photos: { bundle: Bundle; photo: SrcPhoto }[]; +} + +const has = (v: unknown) => v !== undefined && v !== null && v !== '' && !(Array.isArray(v) && !v.length); +const minIso = (a: string, b: string) => (a < b ? a : b); +const maxIso = (a: string, b: string) => (a > b ? a : b); + +/** Groups members by email across bundles. Bundles are in priority order (newest system first). */ +export function mergeMembers(bundles: Bundle[]): MergedMember[] { + const byEmail = new Map(); + for (const b of bundles) { + for (const src of b.members) { + const email = src.email.trim().toLowerCase(); + const cur = byEmail.get(email); + const photos = src.photos.map((photo) => ({ bundle: b, photo })); + if (!cur) { + byEmail.set(email, { email, sources: [b.info.source], keys: [src.key], m: structuredClone(src), photos }); + continue; + } + const m = cur.m; + cur.keys.push(src.key); + if (!cur.sources.includes(b.info.source)) cur.sources.push(b.info.source); + for (const [k, v] of Object.entries(src.fields)) if (!has(m.fields[k]) && has(v)) m.fields[k] = v; + if (!m.gender && src.gender) m.gender = src.gender; + if (!m.seeking.length) m.seeking = src.seeking; + if (!m.birthDate) m.birthDate = src.birthDate; + 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; + m.createdAt = minIso(m.createdAt, src.createdAt); + m.lastActiveAt = maxIso(m.lastActiveAt, src.lastActiveAt); + m.flags = [...new Set([...m.flags, ...src.flags])]; + cur.photos.push(...photos); + } + } + return [...byEmail.values()]; +} + +/** Picks up to 1 main, 6 public and 6 private. A second "main" becomes public. Same image twice is kept once. */ +export function choosePhotos(list: T[]): (T & { kind: PhotoKind })[] { + const out: (T & { kind: PhotoKind })[] = []; + const seen = new Set(); + const count = (k: PhotoKind) => out.filter((p) => p.kind === k).length; + for (const p of list) { + if (seen.has(p.hash)) continue; + let kind = p.photo.kind; + if (kind === 'main' && count('main') >= 1) kind = 'public'; + if (count(kind) >= PHOTO_LIMITS[kind]) continue; + seen.add(p.hash); + out.push({ ...p, kind }); + } + return out; +} + +/** Only answers this site has a field for, and only options that field offers. */ +export function keepFields(defs: ProfileFieldDef[], fields: SrcMember['fields']): Member['fields'] { + const out: Member['fields'] = {}; + for (const def of defs) { + const v = fields[def.key]; + if (!has(v)) continue; + if (def.type === 'select' && typeof v === 'string' && def.options?.includes(v)) out[def.key] = v; + else if (def.type === 'multiselect' && Array.isArray(v)) { + const ok = v.filter((x) => def.options?.includes(x)); + if (ok.length) out[def.key] = ok; + } else if ((def.type === 'height' || def.type === 'number') && typeof v === 'number') out[def.key] = v; + else if (def.type === 'text' && typeof v === 'string') out[def.key] = v; + } + return out; +} + +export async function resolvePlace(geo: GeoProvider, loc: SrcLocation): Promise { + if (loc.country && loc.postal) { const p = await geo.postal(loc.country, loc.postal); if (p) return p; } + if (loc.lat && loc.lng && Math.abs(loc.lat) <= 90 && Math.abs(loc.lng) <= 180) { const p = await geo.nearest(loc.lat, loc.lng); if (p) return p; } + if (loc.city) { const [p] = await geo.search(loc.country, loc.city, 1); if (p) return p; } + return null; +} + +export interface LoadDeps { + site: Site; + repo: SiteRepo; + crypto: SiteCrypto; + geo: GeoProvider; + photos?: PhotoStore; // without it, photos are counted but not copied + now: Date; + dryRun: boolean; +} + +export interface LoadReport { + site: string; + dryRun: boolean; + bundles: { source: string; members: number }[]; + members: Record; + photos: Record; + relations: Record; + moderation: number; +} + +const short = (s: string) => createHash('sha256').update(s).digest('hex').slice(0, 24); + +export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise { + for (const b of bundles) { + if (b.info.site !== d.site.slug) throw new Error(`This bundle is for "${b.info.site}", not "${d.site.slug}". Sites never share data.`); + } + const at = d.now.toISOString(); + const year = d.now.getUTCFullYear(); + const report: LoadReport = { + site: d.site.slug, dryRun: d.dryRun, bundles: bundles.map((b) => ({ source: b.info.source, members: b.members.length })), + members: {}, photos: {}, relations: {}, moderation: 0, + }; + const idByKey = new Map(); + const moderation: ModerationItem[] = []; + const flagItem = (memberId: string, refId: string, kind: ModerationItem['kind'], summary: string, reason: string, createdAt = at) => + moderation.push({ id: 'mod_imp_' + short(`${kind}:${refId}:${reason}`), kind, refId, memberId, summary, reasons: [reason], status: 'pending', createdAt }); + + for (const g of mergeMembers(bundles)) { + const emailHash = await d.crypto.lookupHash(g.email); + const existing = await d.repo.findMemberByHash('email', emailHash); + if (g.sources.length > 1) bump(report.members, 'in more than one old database (merged)'); + if (existing && !existing.imported) { + for (const k of g.keys) idByKey.set(k, existing.id); + bump(report.members, 'already joined the new site (kept as is, history attached)'); + continue; + } + const id = existing?.id ?? IMPORT_ID_PREFIX + (await d.crypto.lookupHash('import-member:' + g.email)).slice(0, 24); + for (const k of g.keys) idByKey.set(k, id); + if (existing?.imported && existing.lastActiveAt > existing.imported.at) { + bump(report.members, 'used the new site since the last run (profile kept)'); + continue; + } + const src = g.m; + 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)'); + const birthYear = src.birthDate ? Number(src.birthDate.slice(0, 4)) : NaN; + const age = year - birthYear; + const ageOk = Number.isFinite(age) && age >= 18 && age <= 100; + if (!ageOk) bump(report.members, 'no usable birth date (asked on first sign-in)'); + let ageMin = src.ageMin ?? (ageOk ? age - 10 : 25); + let ageMax = src.ageMax ?? (ageOk ? age + 10 : 50); + ageMin = Math.min(99, Math.max(18, ageMin)); ageMax = Math.min(99, Math.max(18, ageMax)); + if (ageMin > ageMax) [ageMin, ageMax] = [ageMax, ageMin]; + const fields = keepFields(d.site.fields, src.fields); + const missingRequired = d.site.fields.some((f) => f.required && !has(fields[f.key])); + if (missingRequired) bump(report.members, 'missing a required answer (asked on first sign-in)'); + const member: Member = { + ...(existing ?? {}), + id, + displayName: displayNameFrom(src.username), + 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, + birthYear: ageOk ? birthYear : year - 30, + gender, + seeking: seekingFor(gender, src.seeking), + ageMin, ageMax, + city: place?.name ?? '', region: place?.region ?? '', country: place?.country ?? src.location.country ?? '', + postal: place?.postal ?? '', lat: place?.lat ?? 0, lng: place?.lng ?? 0, + units: existing?.units ?? (place ? unitsForCountry(place.country) : undefined), + about: src.about, + fields, + status: existing?.status ?? 'active', + tier: existing?.tier ?? 'free', + hideExplicit: existing?.hideExplicit ?? true, + createdAt: src.createdAt, + lastActiveAt: src.lastActiveAt, + imported: { sources: g.sources, at }, + }; + bump(report.members, existing ? 'updated from an earlier run' : 'new'); + if (!member.profileComplete) bump(report.members, 'incomplete (finish profile on first sign-in)'); + if (!d.dryRun) await d.repo.saveMember(member); + + 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 (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'); + + // Photos + const withHash: { bundle: Bundle; photo: SrcPhoto; hash: string; data: Buffer }[] = []; + for (const p of g.photos) { + try { + const data = await readFile(photoPath(p.bundle, p.photo.file)); + withHash.push({ ...p, data, hash: createHash('sha256').update(data).digest('hex') }); + } catch { bump(report.photos, 'file missing from bundle'); } + } + const picked = choosePhotos(withHash); + if (withHash.length > picked.length) bump(report.photos, 'duplicate or over the limit', withHash.length - picked.length); + let sort = 0; + for (const p of picked) { + const photoId = 'ph_imp_' + short(id + ':' + p.hash); + const blobKey = `${id}/${photoId}`; + const explicitBlocked = p.photo.explicit && !d.site.settings.explicitPhotosAllowed; + const approved = p.photo.approved && !p.photo.explicit; + const photo: Photo = { + id: photoId, memberId: id, kind: p.photo.explicit ? 'private' : p.kind, + rating: p.photo.explicit ? (explicitBlocked ? 'suggestive' : 'explicit') : 'safe', + status: approved ? 'approved' : 'pending', blobKey, sort: p.kind === 'main' ? 0 : p.kind === 'public' ? 1 + sort : 10 + sort, + createdAt: p.photo.createdAt, + }; + sort++; + if (!approved) flagItem(id, photoId, 'photo', p.photo.explicit ? 'Imported photo marked explicit on the old site' : 'Imported photo not yet approved on the old site', 'imported photo needs review', p.photo.createdAt); + if (!d.dryRun) { + if (d.photos) await d.photos.put(d.site, blobKey, p.data, 'image/jpeg'); + else { bump(report.photos, 'not copied (no photo storage configured)'); continue; } + await d.repo.savePhoto(photo); + } + bump(report.photos, approved ? 'approved' : 'waiting for review'); + } + } + + // Likes, favorites, blocks, views, private photo access, messages + for (const b of bundles) { + for (const r of b.relations) { + const from = idByKey.get(r.from), to = idByKey.get(r.to); + if (!from || !to || from === to) { bump(report.relations, `${r.type} skipped (member not imported)`); continue; } + bump(report.relations, r.type === 'access' ? 'private photo access' : r.type + 's'); + if (d.dryRun) continue; + switch (r.type) { + case 'like': await d.repo.addLike({ fromId: from, toId: to, at: r.at }); break; + case 'favorite': await d.repo.setFavorite({ fromId: from, toId: to, at: r.at }, true); break; + case 'block': await d.repo.addBlock({ blockerId: from, blockedId: to, at: r.at }); break; + case 'view': await d.repo.recordView({ viewerId: from, viewedId: to, at: r.at }); break; + case 'access': await d.repo.saveAccess({ ownerId: from, viewerId: to, status: 'granted', updatedAt: r.at }); break; + case 'message': + await d.repo.saveMessage({ + id: 'msg_imp_' + short(r.id), fromId: from, toId: to, body: r.body, flags: [], held: false, senderTier: 'free', + at: r.at, readAt: r.read ? r.at : undefined, + }); + break; + } + } + } + + report.moderation = moderation.length; + if (!d.dryRun) for (const item of moderation) { + const prior = await d.repo.getModeration(item.id); + if (!prior) await d.repo.saveModeration(item); // a moderator's earlier decision stays + } + return report; +} + +/** Removes every imported member (and, through the database, their photos, likes and messages). Demo and real sign-ups are untouched. */ +export async function removeImported(repo: SiteRepo, site: Site, photos: PhotoStore | undefined, dryRun: boolean) { + let removed = 0; + const ids: string[] = []; + for (let offset = 0; ; offset += 500) { + const { rows } = await repo.listAllMembers(500, offset); + ids.push(...rows.filter((m) => m.id.startsWith(IMPORT_ID_PREFIX) && m.imported).map((m) => m.id)); + if (rows.length < 500) break; + } + for (const id of ids) { + if (!dryRun) { + for (const p of await repo.listPhotos(id)) if (p.blobKey) await photos?.delete(site, p.blobKey); + await repo.deleteMember(id); + } + removed++; + } + return { site: site.slug, dryRun, removed }; +} diff --git a/apps/api/src/import/map.ts b/apps/api/src/import/map.ts new file mode 100644 index 0000000..e36c9cb --- /dev/null +++ b/apps/api/src/import/map.ts @@ -0,0 +1,181 @@ +// How answers on the old sites become AfterH profile fields on the new platform. +// Pure functions, unit tested in test/import-map.test.ts. See infra/import-members.md for the table. +import type { Gender } from '@whatbox/core'; +import type { SrcGender } from './bundle'; + +const uniq = (xs: T[]) => [...new Set(xs)]; +/** SkaDate stores multi-choice answers as a bitmask of the option values (1, 2, 4, 8...). */ +export const bits = (n: number | null | undefined): number[] => { + const out: number[] = []; + for (let b = 1, v = Number(n ?? 0); b <= v && b > 0; b *= 2) if (v & b) out.push(b); + return out; +}; + +// ---------- STD status (AfterH "hsv_status", multi-select) ---------- + +/** Old site "STD Type": colon-separated, e.g. "HSV 1 - Orally:HSV 2 - Genitally". */ +export function legacyStatus(answer: string | undefined): string[] | undefined { + if (!answer) return undefined; + const out = answer.split(':').map((s) => s.trim()).filter(Boolean).map((s) => + /^HSV\s*1/i.test(s) ? 'HSV-1' : /^HSV\s*2/i.test(s) ? 'HSV-2' : /^HPV/i.test(s) ? 'HPV' : 'Other'); + return out.length ? uniq(out) : undefined; +} + +const SKA_STATUS: Record = { 1: 'HSV-1', 2: 'HSV-2', 4: 'Herpes (type unsure)', 8: 'HPV', 16: 'Other' }; +export function skadateStatus(mask: number | undefined): string[] | undefined { + const out = bits(mask).map((b) => SKA_STATUS[b]).filter(Boolean); + return out.length ? uniq(out) : undefined; +} + +// ---------- Relationship goal (single) ---------- +// Old sites allowed several; we keep the most committed one they picked. +const GOAL_RANK = ['Long-term', 'Dating', 'Friendship']; +const pickGoal = (xs: string[]) => GOAL_RANK.find((g) => xs.includes(g)); + +export function legacyGoal(answer: string | undefined): string | undefined { + if (!answer) return undefined; + const map: Record = { 'Something serious': 'Long-term', Dates: 'Dating', Sex: 'Dating', Friendship: 'Friendship', Chat: 'Friendship' }; + return pickGoal(answer.split(':').map((s) => map[s.trim()]).filter(Boolean)); +} +const SKA_GOAL: Record = { 1: 'Dating', 4: 'Dating', 8: 'Friendship', 16: 'Long-term', 32: 'Long-term' }; +export const skadateGoal = (mask: number | undefined) => pickGoal(bits(mask).map((b) => SKA_GOAL[b]).filter(Boolean)); + +// ---------- Kids ---------- +export function legacyKids(have: string | undefined, want: string | undefined): string | undefined { + if (!have) return undefined; + const hasKids = /^yes/i.test(have); + const wants = /^(yes|not sure)/i.test(want ?? ''); + if (hasKids) return /^yes/i.test(want ?? '') ? 'Have kids, want more' : 'Have kids'; + return wants ? 'None, open to it' : 'None'; +} + +// ---------- Smoking / drinking ---------- +export function legacySmoking(a: string | undefined) { + if (!a) return undefined; + return a === 'No' ? 'Never' : a === 'Sometimes' ? 'Sometimes' : 'Regularly'; +} +export function legacyDrinking(a: string | undefined) { + if (!a) return undefined; + return a === 'No' ? 'Never' : a === 'Only in company' ? 'Socially' : 'Regularly'; +} +// SkaDate: 1 Never, 2 Quit, 4 Rarely, 8 Socially, 16 Often, 32 Very often +export function skadateSmoking(v: number | undefined) { + return !v ? undefined : v <= 2 ? 'Never' : v <= 8 ? 'Sometimes' : 'Regularly'; +} +export function skadateDrinking(v: number | undefined) { + return !v ? undefined : v <= 2 ? 'Never' : v <= 8 ? 'Socially' : 'Regularly'; +} + +// ---------- Height (stored in cm) ---------- +export function legacyHeight(a: string | undefined): number | undefined { + const m = /(\d{2,3})\s*cm/i.exec(a ?? ''); + return m ? Number(m[1]) : undefined; +} +/** SkaDate height option n is 3'0" + (n - 1) inches. */ +export function skadateHeight(v: number | undefined): number | undefined { + return v && v > 0 && v < 60 ? Math.round((35 + v) * 2.54) : undefined; +} + +// ---------- Interests (SkaDate "Favorite way to spend time") ---------- +const SKA_INTERESTS: Record = { + 1: 'Reading', 8: 'Live music', 64: 'Hiking', 128: 'Fitness', 2048: 'Reading', 8192: 'Live music', + 65536: 'Cooking', 131072: 'Camping', 262144: 'Fitness', 524288: 'Gaming', 1048576: 'Travel', 4194304: 'Movies', +}; +export function skadateInterests(mask: number | undefined): string[] | undefined { + const out = uniq(bits(mask).map((b) => SKA_INTERESTS[b]).filter(Boolean)); + return out.length ? out : undefined; +} + +// ---------- Gender ---------- +/** Old site: 1 man, 2 woman, 3 couple. */ +export const legacyGender = (g: number | null | undefined): SrcGender | null => (g === 1 ? 'man' : g === 2 ? 'woman' : g === 3 ? 'couple' : null); +/** SkaDate "sex" / "match_sex" bitmask: 1 male, 2 female, 4 couple. */ +export const skadateGenders = (mask: number | undefined): SrcGender[] => + bits(mask).map((b): SrcGender | null => (b === 1 ? 'man' : b === 2 ? 'woman' : b === 4 ? 'couple' : null)).filter((g): g is SrcGender => !!g); + +/** Couples aren't a profile type on the new platform yet, so they drop out of "looking for". */ +export function seekingFor(gender: Gender, seeking: SrcGender[]): Gender[] { + const s = uniq(seeking.filter((g): g is Gender => g !== 'couple')); + if (s.length) return s; + return gender === 'woman' ? ['man'] : gender === 'man' ? ['woman'] : ['woman', 'man', 'nonbinary']; +} + +// ---------- Text ---------- +/** Plain text from an old profile or message: tags removed, entities decoded, whitespace tidied. */ +export function cleanText(s: string | null | undefined): string { + return (s ?? '') + .replace(//gi, '\n').replace(/<\/p>/gi, '\n\n').replace(/<[^>]+>/g, '') + .replace(/ /g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'") + .replace(/\r/g, '').replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim(); +} + +/** "About me", with who they'd like to meet as a second paragraph. Kept under the new 2,000 character limit. */ +export function joinAbout(about: string[], meet: string | undefined, max = 2000): string { + const parts = uniq(about.map(cleanText).filter(Boolean)); + const m = cleanText(meet); + if (m) parts.push(`Who I'd like to meet: ${m}`); + const s = parts.join('\n\n'); + return s.length <= max ? s : s.slice(0, max - 1).trimEnd() + '…'; +} + +/** Display names on the new platform: the old public username, tidied and capped. */ +export function displayNameFrom(username: string): string { + const s = username.replace(/[_.]+/g, ' ').replace(/\s+/g, ' ').trim(); + return (s || 'Member').slice(0, 30); +} + +// ---------- Countries ---------- +const ALIASES: Record = { + 'united states': 'US', usa: 'US', 'united states of america': 'US', 'russian federation': 'RU', russia: 'RU', + 'united kingdom': 'GB', uk: 'GB', 'great britain': 'GB', 'korea, republic of': 'KR', 'south korea': 'KR', + 'viet nam': 'VN', 'iran, islamic republic of': 'IR', 'czech republic': 'CZ', 'puerto rico': 'PR', +}; +let byName: Map | undefined; +/** Country name as the old site stored it ("United States") to an ISO code ("US"). */ +export function countryCode(name: string | null | undefined): string | undefined { + const n = (name ?? '').trim().toLowerCase(); + if (!n) return undefined; + if (/^[a-z]{2}$/.test(n)) return n.toUpperCase(); + if (ALIASES[n]) return ALIASES[n]; + if (!byName) { + byName = new Map(); + const dn = new Intl.DisplayNames(['en'], { type: 'region' }); + for (let a = 65; a <= 90; a++) for (let b = 65; b <= 90; b++) { + const code = String.fromCharCode(a, b); + try { const label = dn.of(code); if (label && label !== code) byName.set(label.toLowerCase(), code); } catch { /* not a region */ } + } + } + return byName.get(n); +} + +export const isoDate = (d: Date | string | number | null | undefined): string | undefined => { + if (d === null || d === undefined || d === '') return undefined; + const t = typeof d === 'number' ? new Date(d * 1000) : new Date(d); + return Number.isFinite(t.getTime()) ? t.toISOString() : undefined; +}; + +// ---------- Site-specific question 20 (and 21) on the old sites ---------- + +/** HFriends "Type of Disability" (q20) and "Type of Disorder" (q21) to "About my disability". */ +export function legacyAccessibility(disability: string | undefined, disorder: string | undefined): string[] | undefined { + const out: string[] = []; + for (const raw of [...(disability ?? '').split(':'), ...(disorder ?? '').split(':')]) { + const s = raw.trim().toLowerCase(); + if (!s || s === 'none' || s === 'no disability') continue; + if (/paraplegic|quadriplegic|spinal|spina bifida/.test(s)) out.push('Wheelchair user'); + else if (/mobility|physically|amputee|hemiplegic|polio|muscular dystrophy|arthrogryposis|brittle bone|osteogenesis|cerebral palsy|charcot/.test(s)) out.push('Uses a mobility aid'); + else if (/hearing/.test(s)) out.push('Deaf or hard of hearing'); + else if (/vision/.test(s)) out.push('Blind or low vision'); + else if (/learning|asperger/.test(s)) out.push('Neurodivergent'); + else if (/speech|other/.test(s)) continue; // no matching option; the member can add it after signing in + else out.push('Chronic illness'); + } + return out.length ? uniq(out) : undefined; +} + +/** DateALittle "Dwarfism Type" (q20) to "Stature". The exact type isn't carried over (no matching field yet). */ +export function legacyStature(answer: string | undefined): string | undefined { + const s = (answer ?? '').trim(); + if (!s) return undefined; + return /^none$/i.test(s) ? 'Average height' : 'Little person'; +} diff --git a/apps/api/src/import/skadate.ts b/apps/api/src/import/skadate.ts new file mode 100644 index 0000000..0921e7d --- /dev/null +++ b/apps/api/src/import/skadate.ts @@ -0,0 +1,173 @@ +// Extractor for the current AfterH site (SkaDate 10 on Oxwall, MySQL/MariaDB). +// Reads a restored copy of the .sql dump and writes a bundle. Never writes to the source. +// +// SkaDate keeps photo files on the web server (ow_userfiles), not in the database. Pass that +// folder as photosDir to bring photos across; without it members come over without photos. +import mysql from 'mysql2/promise'; +import { readdir, readFile, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import { normalizeImage } from '../photos'; +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, + skadateSmoking, skadateStatus, +} from './map'; + +// Profile question names in this SkaDate install (labels from its language tables). +const Q = { + sex: 'sex', matchSex: 'match_sex', birthdate: 'birthdate', matchAge: 'match_age', relationship: 'relationship', + aboutMe: 'aboutme', ownWords: '6ed883b3412cab27014a0b68ea32f269', meet: '9f427b5a957edde93cc955fa13971799', + std: 'field_c8bc1f0f0fd3cff7b2a73ac34d75425a', height: 'field_896bc24ae1d1eb874a3c1709700418d8', + smoking: '31d5d3d7ff420e340cfe3f17c534eba3', drinking: '6341ee69d879c97cb0c47507a557372c', + interests: 'a69350b819c8dc1d926cba6b58451f5f', +}; +const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + +async function fileIndex(dir: string | undefined): Promise> { + const idx = new Map(); + if (!dir) return idx; + for (const e of await readdir(dir, { recursive: true, withFileTypes: true })) { + if (e.isFile()) idx.set(e.name.toLowerCase(), join(e.parentPath, e.name)); + } + return idx; +} +/** The biggest copy SkaDate kept: original, then full screen, then the smaller sizes. */ +function findFile(idx: Map, prefixes: string[]): string | undefined { + for (const p of prefixes) for (const ext of ['jpg', 'jpeg', 'png', 'gif', 'webp']) { + const hit = idx.get(`${p}.${ext}`.toLowerCase()); + if (hit) return hit; + } + return undefined; +} + +export async function extractSkadate(url: string, outDir: string, opts: { photosDir?: string } = {}) { + await prepareBundleDir(outDir); + const db = await mysql.createConnection({ uri: url, dateStrings: false, supportBigNumbers: true, bigNumberStrings: false }); + const q = async (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 data = new Map>(); + 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 }); + } + const locs = new Map(); + 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 members: SrcMember[] = []; + const keep = new Set(); + const seenEmail = new Set(); + for (const u of users) { + const d = data.get(u.id) ?? new Map(); + const email = String(u.email ?? '').trim().toLowerCase(); + const [gender] = skadateGenders(d.get(Q.sex)?.i); + if (gender === 'couple') { bump(info.skipped, 'couple profile (not supported yet)'); continue; } + if (!gender) { bump(info.skipped, 'no gender'); continue; } + if (!EMAIL_RE.test(email)) { bump(info.skipped, 'no usable email'); continue; } + if (seenEmail.has(email)) { bump(info.skipped, 'second account with the same email'); continue; } + seenEmail.add(email); + const fields: SrcMember['fields'] = {}; + const set = (k: string, v: string | string[] | number | undefined) => { if (v !== undefined) fields[k] = v; }; + set('hsv_status', skadateStatus(d.get(Q.std)?.i)); + set('relationship_goal', skadateGoal(d.get(Q.relationship)?.i)); + set('height', skadateHeight(d.get(Q.height)?.i)); + set('smoking', skadateSmoking(d.get(Q.smoking)?.i)); + set('drinking', skadateDrinking(d.get(Q.drinking)?.i)); + set('interests', skadateInterests(d.get(Q.interests)?.i)); + const range = /^(\d+)\s*-\s*(\d+)$/.exec(d.get(Q.matchAge)?.t ?? ''); + const birth = d.get(Q.birthdate)?.d; + const loc = locs.get(u.id); + const place = loc ? placeFromGoogle(loc) : {}; + const flags: string[] = []; + if (notApproved.has(u.id)) flags.push('not_approved'); + if (suspended.has(u.id)) flags.push('suspended'); + members.push({ + key: 'skadate:' + u.id, + email, + username: String(u.username ?? ''), + gender, + seeking: skadateGenders(d.get(Q.matchSex)?.i), + birthDate: birth && birth.getUTCFullYear() > 1900 ? isoDate(birth)!.slice(0, 10) : undefined, + ageMin: range ? Number(range[1]) : undefined, + ageMax: range ? Number(range[2]) : undefined, + location: place, + about: joinAbout([d.get(Q.aboutMe)?.t ?? '', d.get(Q.ownWords)?.t ?? ''], d.get(Q.meet)?.t), + fields, + createdAt: isoDate(u.joinStamp) ?? info.extractedAt, + lastActiveAt: isoDate(u.activityStamp) ?? isoDate(u.joinStamp) ?? info.extractedAt, + flags, + photos: [], + }); + keep.add(u.id); + } + const byId = new Map(members.map((m) => [Number(m.key.slice(8)), m])); + + // Photos: the avatar becomes the main photo, then album photos in upload order. + const files = await fileIndex(opts.photosDir); + const addPhoto = async (m: SrcMember, path: string | undefined, file: string, p: Omit) => { + if (!path) { bump(info.skipped, opts.photosDir ? 'photo file not found in the photos folder' : 'photo files not provided'); return; } + if (p.kind !== 'main' && m.photos.filter((x) => x.kind === p.kind).length >= 6) { bump(info.skipped, `${p.kind} photo over the limit of 6`); return; } + try { + const { data } = await normalizeImage(await readFile(path)); + await writeFile(photoPath({ dir: outDir }, file), data, { mode: 0o600 }); + m.photos.push({ file, ...p }); + } catch { bump(info.skipped, 'photo file unreadable'); } + }; + for (const a of await q(`SELECT id, userId, hash, status FROM ow_base_avatar ORDER BY id`)) { + const m = byId.get(a.userId); + if (!m || m.photos.some((x) => x.kind === 'main')) continue; + const path = findFile(files, [`avatar_original_${a.userId}_${a.hash}`, `avatar_big_${a.userId}_${a.hash}`, `avatar_${a.userId}_${a.hash}`]); + await addPhoto(m, path, `skadate-avatar-${a.id}.jpg`, { kind: 'main', approved: a.status === 'active', explicit: false, createdAt: m.createdAt }); + } + for (const p of await q(`SELECT p.id, p.hash, p.status, p.privacy, p.addDatetime, a.userId FROM ow_photo p JOIN ow_photo_album a ON a.id=p.albumId ORDER BY p.id`)) { + const m = byId.get(p.userId); + if (!m) { bump(info.skipped, 'photo of a member not imported'); continue; } + if (p.status === 'blocked') { bump(info.skipped, 'photo blocked on the old site'); continue; } + const kind: SrcPhoto['kind'] = p.privacy && p.privacy !== 'everybody' ? 'private' : !m.photos.some((x) => x.kind === 'main') ? 'main' : 'public'; + const path = findFile(files, [`photo_original_${p.id}_${p.hash}`, `photo_fullscreen_${p.id}_${p.hash}`, `photo_main_${p.id}_${p.hash}`, `photo_${p.id}_${p.hash}`]); + await addPhoto(m, path, `skadate-${p.id}.jpg`, { kind, approved: p.status === 'approved', explicit: false, createdAt: isoDate(p.addDatetime) ?? m.createdAt }); + } + + const relations: SrcRelation[] = []; + const key = (id: number) => 'skadate:' + id; + const rel = (type: 'like' | 'favorite' | 'block' | 'view', from: number, to: number, at: number | null) => { + if (keep.has(from) && keep.has(to) && from !== to) relations.push({ type, from: key(from), to: key(to), at: isoDate(at) ?? info.extractedAt }); + else bump(info.skipped, `${type} with a member not imported`); + }; + for (const r of await q(`SELECT userId, markUserId FROM ow_bookmarks_mark`)) rel('favorite', r.userId, r.markUserId, null); + for (const r of await q(`SELECT userId, blockedUserId FROM ow_base_user_block`)) rel('block', r.userId, r.blockedUserId, null); + for (const r of await q(`SELECT userId, partnerId, timestamp FROM ow_winks_winks`)) rel('like', r.userId, r.partnerId, r.timestamp); + for (const r of await q(`SELECT guestId, userId, visitTimestamp FROM ow_ocsguests_guest`)) rel('view', r.guestId, r.userId, r.visitTimestamp); + for (const r of await q(`SELECT id, senderId, recipientId, timeStamp, text, recipientRead, isSystem FROM ow_mailbox_message ORDER BY id`)) { + if (r.isSystem || /^\s*\{/.test(r.text ?? '')) { bump(info.skipped, 'system message (wink, gift...)'); continue; } + const body = cleanText(r.text); + if (!body) { bump(info.skipped, 'empty message'); continue; } + if (!keep.has(r.senderId) || !keep.has(r.recipientId)) { bump(info.skipped, 'message with a member not imported'); continue; } + relations.push({ type: 'message', id: 'skadate-' + r.id, from: key(r.senderId), to: key(r.recipientId), at: isoDate(Number(r.timeStamp))!, body, read: !!r.recipientRead }); + } + + info.counts = countBundle(members, relations); + await writeBundle(outDir, info, members, relations); + return info; + } finally { + await db.end(); + } +} + +/** Town, region and postcode from the Google geocode SkaDate saved. The street address is dropped. */ +function placeFromGoogle(loc: { countryCode: string; lat: string | number; lng: string | number; json: string }) { + let comps: { short_name: string; long_name: string; types: string[] }[] = []; + try { comps = JSON.parse(loc.json)?.address_components ?? []; } catch { /* keep coordinates only */ } + const get = (t: string, short = false) => { const c = comps.find((x) => x.types?.includes(t)); return c ? (short ? c.short_name : c.long_name) : undefined; }; + return { + country: (loc.countryCode || get('country', true) || '').toUpperCase() || undefined, + region: get('administrative_area_level_1', true), + city: get('locality') ?? get('postal_town') ?? get('administrative_area_level_2'), + postal: get('postal_code'), + lat: Number(loc.lat) || undefined, + lng: Number(loc.lng) || undefined, + }; +} diff --git a/apps/api/test/import.test.ts b/apps/api/test/import.test.ts new file mode 100644 index 0000000..92884db --- /dev/null +++ b/apps/api/test/import.test.ts @@ -0,0 +1,102 @@ +// Member import: answer mapping, merging people found in both AfterH databases, photo limits, +// and the site guard. Uses made-up members only. +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { DevKeyProvider, MemorySiteRepo, SiteCrypto, seedSites } from '@whatbox/core'; +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, +} from '../src/import/map'; +import { choosePhotos, keepFields, loadBundles, mergeMembers } from '../src/import/load'; + +test('AfterH status from both old systems', () => { + assert.deepEqual(legacyStatus('HSV 1 - Orally:HSV 2 - Genitally:HPV (Genital Warts)'), ['HSV-1', 'HSV-2', 'HPV']); + assert.deepEqual(legacyStatus('HSV 1 - Orally:HSV 1 - Genitally'), ['HSV-1']); + assert.equal(legacyStatus(''), undefined); + assert.deepEqual(skadateStatus(1 | 2), ['HSV-1', 'HSV-2']); + assert.deepEqual(skadateStatus(4 | 16), ['Herpes (type unsure)', 'Other']); + assert.deepEqual(bits(21), [1, 4, 16]); +}); + +test('profile answers', () => { + assert.equal(legacyGoal('Dates:Something serious'), 'Long-term'); + assert.equal(legacyGoal('Chat'), 'Friendship'); + assert.equal(skadateGoal(1 | 8), 'Dating'); + assert.equal(legacyHeight(`5' 6" - 168cm`), 168); + assert.equal(legacyHeight(`3' 0" - 91 cm`), 91); // DateALittle writes a space + assert.equal(skadateHeight(31), 168); // 5'6" + assert.equal(legacyKids('No', 'Not Sure'), 'None, open to it'); + assert.equal(legacyKids('Yes - but not at home', 'Yes'), 'Have kids, want more'); + assert.deepEqual(skadateInterests(1 | 2048 | 1048576), ['Reading', 'Travel']); + assert.deepEqual(legacyAccessibility('Paraplegic:Hearing Impaired', 'Multiple Sclerosis'), ['Wheelchair user', 'Deaf or hard of hearing', 'Chronic illness']); + assert.equal(legacyAccessibility('No Disability', 'None'), undefined); + assert.equal(legacyStature('Achondroplasia'), 'Little person'); + assert.equal(legacyStature('None'), 'Average height'); + assert.deepEqual(skadateGenders(1 | 4), ['man', 'couple']); + assert.deepEqual(seekingFor('man', ['couple']), ['woman']); + assert.equal(countryCode('United States'), 'US'); + assert.equal(countryCode('Russian Federation'), 'RU'); + assert.equal(countryCode('Netherlands'), 'NL'); + assert.equal(cleanText('Hi
there & you'), 'Hi\nthere & you'); + assert.equal(joinAbout(['Same', 'Same'], 'someone kind'), "Same\n\nWho I'd like to meet: someone kind"); +}); + +test('only fields the site has, with its options', () => { + const afterh = seedSites(new Date())[0]; + const f = keepFields(afterh.fields, { hsv_status: ['HSV-2', 'Nope'], smoking: 'Never', stature: 'Little person', height: 170 }); + assert.deepEqual(f, { hsv_status: ['HSV-2'], height: 170, smoking: 'Never' }); +}); + +const src = (over: Partial): SrcMember => ({ + key: 'x:1', email: 'a@example.com', username: 'sunny', gender: 'woman', seeking: ['man'], birthDate: '1985-04-02', + location: { country: 'US', postal: '80202' }, about: '', fields: {}, createdAt: '2020-01-01T00:00:00.000Z', + lastActiveAt: '2021-01-01T00:00:00.000Z', flags: [], photos: [], ...over, +}); +const bundle = (source: 'skadate' | 'aspnetdating', members: SrcMember[], site = 'afterh', relations: Bundle['relations'] = []): Bundle => + ({ dir: '/nonexistent', info: { source, site, extractedAt: '', counts: {}, skipped: {} }, members, relations }); + +test('one person in both AfterH databases becomes one member', () => { + const newer = bundle('skadate', [src({ key: 'skadate:7', email: 'A@Example.com ', fields: { hsv_status: ['HSV-2'] }, createdAt: '2025-11-20T00:00:00.000Z', lastActiveAt: '2026-10-01T00:00:00.000Z' })]); + const older = bundle('aspnetdating', [ + src({ key: 'legacy:sunny', fields: { hsv_status: ['HSV-1'], height: 165 }, about: 'Old about', createdAt: '2009-03-01T00:00:00.000Z' }), + src({ key: 'legacy:other', email: 'b@example.com' }), + ]); + const merged = mergeMembers([newer, older]); + assert.equal(merged.length, 2); + const m = merged.find((x) => x.email === 'a@example.com')!; + assert.deepEqual(m.keys, ['skadate:7', 'legacy:sunny']); + assert.deepEqual(m.m.fields, { hsv_status: ['HSV-2'], height: 165 }); // newer wins, older fills gaps + assert.equal(m.m.about, 'Old about'); + assert.equal(m.m.createdAt, '2009-03-01T00:00:00.000Z'); + assert.equal(m.m.lastActiveAt, '2026-10-01T00:00:00.000Z'); +}); + +test('photo limits and duplicates', () => { + const p = (kind: 'main' | 'public' | 'private', hash: string) => ({ photo: { file: hash, kind, approved: true, explicit: false, createdAt: '' }, hash }); + const out = choosePhotos([p('main', 'a'), p('main', 'b'), p('public', 'a'), ...Array.from({ length: 8 }, (_, i) => p('public', 'p' + i))]); + assert.deepEqual(out.map((x) => x.kind), ['main', ...Array(6).fill('public')]); + assert.equal(out[1].hash, 'b'); // a second main becomes public; the duplicate "a" is dropped +}); + +test('loads into the named site only, and re-runs update instead of duplicating', async () => { + 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', fields: { hsv_status: ['HSV-2'] } }), src({ key: 'skadate:2', email: 'c@example.com', fields: { hsv_status: ['HSV-1'] } })], 'afterh', + [{ type: 'message', id: 'skadate-1', from: 'skadate:1', to: 'skadate:2', at: '2021-01-01T00:00:00.000Z', body: 'hello', read: true }]); + + await assert.rejects(loadBundles([bundle('aspnetdating', [], 'hfriends')], deps), /not "afterh"/); + const before = (await repo.listAllMembers(1000, 0)).total; + const r1 = await loadBundles([b], deps); + assert.equal(r1.members.new, 2); + const r2 = await loadBundles([b], deps); + assert.equal(r2.members['updated from an earlier run'], 2); + assert.equal((await repo.listAllMembers(1000, 0)).total, before + 2); + const m = await repo.findMemberByHash('email', await crypto.lookupHash('a@example.com')); + assert.ok(m?.imported && m.profileComplete && m.city === 'Denver' && m.displayName === 'sunny'); + assert.notEqual(m.emailEnc, 'a@example.com'); + assert.equal((await repo.listMessagesInvolving(m.id)).length, 1); +}); diff --git a/infra/README.md b/infra/README.md index 23ab200..f65f1cb 100644 --- a/infra/README.md +++ b/infra/README.md @@ -45,6 +45,7 @@ deploy is clean. 1. Add its key: `infra/scripts/bootstrap-secrets.sh site_` and restart the API revision. 2. In Platform Admin → Add a site. The API creates the site's database. 3. Domains: Actions → **Custom domains** (records, add, then bind on go-live day). See [go-live-domains.md](go-live-domains.md). +4. Members from the old sites: Actions → **Import members** (dry run, then load). See [import-members.md](import-members.md). ## Payments diff --git a/infra/import-members.md b/infra/import-members.md new file mode 100644 index 0000000..56e5a96 --- /dev/null +++ b/infra/import-members.md @@ -0,0 +1,112 @@ +# Importing members from the old sites + +Brings members, photos and history from the old sites into the new platform, one site at a time. +Each site's data goes only into that site's own database, encrypted with that site's own key, and +its photos only into that site's own photo container. A bundle made for one site is refused by any other. + +| New site | Old systems | Members (Nov 28 backups) | +|---|---|---| +| AfterH | current SkaDate site (MySQL dump) **and** the older AspNetDating site (SQL Server .bak) | 43 + 214, 2 in both | +| HFriends | AspNetDating (.bak) | 3,291 | +| DateALittle | AspNetDating (.bak) | 1,647 | + +Counts are after leaving out deleted accounts and couple profiles (see "Left behind"). + +## How it works + +1. **Extract** (GitHub runner): the backup is restored inside a throwaway runner, and the extractor + writes a *bundle*: members, photos (re-encoded, all metadata stripped) and relations. + Passwords, real names, IP addresses and billing details are never read into the bundle. +2. **Load** (Azure job `whatbox--import`): reads the bundles from the private `imports` + container and writes the site's database and photos. The bundles are deleted afterwards. + +Both steps print counts only. No member names, emails or messages appear in logs. + +### Signing in after the import + +The new platform has no passwords: members sign in with a code sent to their email. An imported +member just types the email they used on the old site and gets a code; they land in their old +profile with their photos, favorites and messages. Nobody needs a password reset, and the old +password hashes (unsalted SHA-1 on the old sites, SkaDate's on the current one) are not carried over. +Email delivery has to work in the target environment for this (see the WhatBox sending domain). + +### AfterH: one person in both systems + +Matched by email (case and spaces ignored). They become one member: +the SkaDate (newer) answers win, the older site fills anything SkaDate didn't have, +"joined" is the earliest date and "last active" the latest. Photos from both are combined +(same image once) up to the limits. Likes, messages, favorites and blocks from both are kept. + +### Running again + +Safe to repeat: member ids come from a keyed hash of the email, so a second run updates the same +members instead of adding copies. Two cases are protected: + +- Someone who **joined the new site** before the import with the same email keeps their new + profile untouched; their old messages, likes and favorites are attached to it. +- An imported member who has **signed in since the last run** keeps whatever they changed. + +`remove` takes every imported member off a site again. Demo data and real sign-ups stay. +Note that the dev "Load demo data" deploy option wipes all member data on dev, imports included. + +## What maps to what + +| Old site | New platform | +|---|---| +| Username | Display name (real names are not carried over) | +| Email | Sign-in email (stored only as a keyed hash plus site-key encryption) | +| Gender / looking for | Gender / looking for. Couples: not supported yet, left behind | +| Birth date | Birth year (missing or under 18: asked at first sign-in) | +| Country, state, city, ZIP, coordinates | The town (city-level coordinates only, never an address) | +| "Tell us about you" + "Who I'd like to meet" (SkaDate: About me + In my own words + About the person I want to meet) | About me (second paragraph "Who I'd like to meet: ...") | +| AfterH STD type | Status: HSV 1 (oral or genital) → HSV-1, HSV 2 → HSV-2, HPV → HPV; SkaDate also "HSV type unknown" → Herpes (type unsure), "Other STD" → Other | +| HFriends Type of disability + Type of disorder | About my disability: paraplegic/quadriplegic/spinal/spina bifida → Wheelchair user; mobility/physical/amputee/CP and similar → Uses a mobility aid; hearing → Deaf or hard of hearing; vision → Blind or low vision; learning disabled/Asperger's → Neurodivergent; other conditions → Chronic illness | +| DateALittle Dwarfism type | Stature: "None" → Average height, any type → Little person | +| Looking for (Something serious / Dates / Sex / Friendship / Chat; SkaDate Here for) | Relationship goal: Long-term / Dating / Friendship (the most committed choice wins) | +| Have kids + want kids | Kids | +| Smoking, drinking, height | Smoking, drinking, height (cm) | +| SkaDate "Favorite way to spend time" | Interests (Reading, Live music, Hiking, Fitness, Cooking, Camping, Gaming, Travel, Movies) | +| Primary photo / other photos / private photos | Main / public / private (up to 1 + 6 + 6) | +| Photos approved on the old site | Approved. Unapproved or explicit ones wait in moderation (explicit ones as private, since explicit photos are off on these sites) | +| Interests (winks), favourites, blocks, profile views, private photo access, mailbox messages | Likes, favorites, blocks, views, granted private access, messages | + +Every member starts on the Free tier (the paywall is off at launch). +Imported members with contact details in "About me", or flagged on the old site (spam suspected, +not approved, suspended), get a moderation item so the site owner can look. + +**Left behind:** deleted accounts, couple profiles, passwords, real names, IP logs, billing and +subscriptions, chat rooms, blogs, photo ratings, polls, ecards, the old Weight / Body type / Eyes / +Hair / Ethnicity / Education / Marital status / Religion / Sexual preference answers (no matching +fields on the new sites yet; they can be added as site fields and the import re-run), and messages +that were never delivered or were deleted by both people. + +**SkaDate photos** are files on the old web server (`ow_userfiles`), not in the database dump. +Without them, the 43 SkaDate members come over without photos (those also on the older site still +get their older photos). Zip the `ow_userfiles` folder from the old host's file manager to bring them. + +## Running it + +1. **Upload the backups** to the environment's storage account, container `imports` + (Azure Portal > Storage accounts > the WhatBox account > Containers > imports > Upload). + Use prod for real data; dev only for test runs. Never put backups in git or chat. +2. Make sure the environment has been deployed with this change (it creates the `imports` + container and the import job), and that the site exists there. +3. Actions > **Import members** > Run workflow: + - environment: `prod` (or `dev` to try it), site, mode `dry-run` first + - legacy_backup: the .bak name, e.g. `db_a631ea_afterh_11_28_2026_10.bak` + - AfterH only: skadate_dump `afterhco_skadate.sql`, and skadate_photos if you have the zip +4. Read the counts in the run summary, then run again with mode `load`. +5. When all three sites are done and checked, delete the backups from the `imports` container. + +### Locally + +``` +# restore the .bak into a local SQL Server and the dump into a local MariaDB (Docker), then: +SOURCE_MSSQL='Server=localhost,1433;Database=legacy;User Id=sa;Password=...;Encrypt=true;TrustServerCertificate=true' \ + npm run import -w @whatbox/api -- extract-legacy --site afterh --out /tmp/b/2-legacy +SOURCE_MYSQL='mysql://root:...@127.0.0.1:3306/skadate' \ + npm run import -w @whatbox/api -- extract-skadate --out /tmp/b/1-skadate [--photos ow_userfiles] +npm run import -w @whatbox/api -- load --site afterh --bundle /tmp/b --dry-run +``` + +A folder given to `--bundle` can hold several bundles; they load in name order, first one winning. diff --git a/infra/main.bicep b/infra/main.bicep index 1b70f46..97c16f2 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -184,6 +184,14 @@ resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2023-05-01' } } +// Private hand-off area for member imports: old-site backups and the bundles made from them. +// No public access. Delete the backups once the import is done (see infra/import-members.md). +resource importsContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2023-05-01' = { + parent: blobService + name: 'imports' + properties: { publicAccess: 'None' } +} + resource storageKeySecret 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = { parent: kv name: 'storage-key' @@ -388,6 +396,40 @@ resource seed 'Microsoft.App/jobs@2024-03-01' = if (deployApps && !prod) { } } +// Loads member bundles from the imports container into one site's database. Started by the +// "Import members" workflow, which first writes what to do (load / remove, which site) to +// imports/jobs/next.json; the job reads and deletes it. Output is counts only. +resource importJob 'Microsoft.App/jobs@2024-03-01' = if (deployApps) { + name: '${name}-import' + location: location + tags: tags + identity: { type: 'UserAssigned', userAssignedIdentities: { '${identity.id}': {} } } + dependsOn: [acrPull, kvRead] + properties: { + environmentId: cae.id + configuration: { + triggerType: 'Manual' + replicaTimeout: 3600 + replicaRetryLimit: 0 + manualTriggerConfig: { parallelism: 1, replicaCompletionCount: 1 } + registries: registries + secrets: apiSecrets + } + template: { + containers: [ + { + name: 'import' + image: '${acr.properties.loginServer}/whatbox-api:${imageTag}' + command: ['node', '--import', 'tsx', 'scripts/import.ts'] + args: ['from-blob'] + resources: { cpu: json('1.0'), memory: '2Gi' } + env: apiEnv + } + ] + } + } +} + resource web 'Microsoft.App/containerApps@2024-03-01' = if (deployApps) { name: '${name}-web' location: location diff --git a/package-lock.json b/package-lock.json index da8591f..8e024f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,17 +21,20 @@ "@nestjs/core": "^11.2.12", "@nestjs/platform-express": "^11.2.12", "@whatbox/core": "^0.1.0", - "all-the-cities": "^3.1.0", + "all-the-cities": "3.1.0", "jose": "^6.2.18", + "mssql": "^12.8.3", + "mysql2": "^3.24.6", "pg": "^8.23.1", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.2", "sharp": "^0.35.5", "tsx": "^4.23.15", - "zipcodes": "^8.0.0" + "zipcodes": "8.0.0" }, "devDependencies": { "@types/express": "^5.0.6", + "@types/mssql": "^12.3.2", "@types/node": "^26.6.11", "@types/pg": "^8.23.1", "typescript": "~6.0.3" @@ -87,7 +90,7 @@ "expo-device": "~58.0.5", "expo-image-picker": "~58.0.10", "expo-linking": "~58.0.17", - "expo-location": "^58.0.23", + "expo-location": "~58.0.23", "expo-notifications": "~58.1.10", "expo-router": "~58.0.33", "expo-status-bar": "~58.0.5", @@ -286,6 +289,15 @@ "node": ">=22.0.0" } }, + "node_modules/@azure/core-process": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@azure/core-process/-/core-process-1.0.0.tgz", + "integrity": "sha512-/shnJ+ooO8WPxDhPEeI/2oRQuubn16gZ6CvlbpWbEswZfzwI9tI/sMAHmF3x1LuQ9yZYXfLW3TjzGMLEC5blKg==", + "license": "MIT", + "engines": { + "node": ">=22.0.0" + } + }, "node_modules/@azure/core-rest-pipeline": { "version": "1.25.1", "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.25.1.tgz", @@ -343,6 +355,102 @@ "node": ">=22.0.0" } }, + "node_modules/@azure/identity": { + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.14.1.tgz", + "integrity": "sha512-HHuuFrmN1uuF9D5A6aAo5eHzNFNX4Q+P4SksZqDKse5YaJFFy/zDLG3wXHEV2FVGgetZ3QM8jGURNBtnQYf1NQ==", + "license": "MIT", + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-auth": "^1.9.0", + "@azure/core-client": "^1.9.2", + "@azure/core-process": "^1.0.0", + "@azure/core-rest-pipeline": "^1.17.0", + "@azure/core-tracing": "^1.0.0", + "@azure/core-util": "^1.11.0", + "@azure/logger": "^1.0.0", + "@azure/msal-browser": "^5.5.0", + "@azure/msal-node": "^7.1.0", + "open": "^11.0.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@azure/identity/node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@azure/identity/node_modules/open": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/open/-/open-11.0.4.tgz", + "integrity": "sha512-++Zlftm0kVLPmzC06t6epuWmcRMDbI4z5P3NNX979WA/k23+NtSOynEGzsVfZwguKw2mi5umVgnBlJQMwRz4Pg==", + "license": "MIT", + "dependencies": { + "default-browser": "^5.5.1", + "define-lazy-prop": "^3.0.0", + "is-in-ssh": "^1.0.0", + "is-inside-container": "^1.0.0", + "powershell-utils": "^0.2.1", + "wsl-utils": "^1.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@azure/keyvault-common": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@azure/keyvault-common/-/keyvault-common-2.1.1.tgz", + "integrity": "sha512-SxpomJRTBfDTQnuii3w10WnZNQJGPNi15tRPdPUQz7BqyB3yk976knEueS7R0H9kSLtXbP0wJZXRh0EbRTQ0lw==", + "license": "MIT", + "dependencies": { + "@azure-rest/core-client": "^2.3.3", + "@azure/abort-controller": "^2.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.8.0", + "@azure/core-tracing": "^1.0.0", + "@azure/core-util": "^1.10.0", + "@azure/logger": "^1.1.4", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@azure/keyvault-keys": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@azure/keyvault-keys/-/keyvault-keys-4.11.0.tgz", + "integrity": "sha512-aj4FiVbwimC/avV4SKJ2ZAmkK1H7fh4XWHYZVBogDRlbUJHuNTZqMRlOI4QKhIvqHQhWMryw2hNtsxyvjY9HHw==", + "license": "MIT", + "dependencies": { + "@azure-rest/core-client": "^2.3.3", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^2.7.2", + "@azure/core-paging": "^1.6.2", + "@azure/core-rest-pipeline": "^1.19.0", + "@azure/core-tracing": "^1.2.0", + "@azure/core-util": "^1.11.0", + "@azure/keyvault-common": "^2.1.0", + "@azure/logger": "^1.1.4", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, "node_modules/@azure/logger": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.4.0.tgz", @@ -356,6 +464,40 @@ "node": ">=22.0.0" } }, + "node_modules/@azure/msal-browser": { + "version": "5.30.0", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-5.30.0.tgz", + "integrity": "sha512-o/ADxWxEFcVrE65a7ssOGuxnivq8lcy+2hSGlOOwtn0gGd6iiwl3q8/BMVRorYE81UB/r4B+8WGEUxWnqP7ryA==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "16.17.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "16.17.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-16.17.0.tgz", + "integrity": "sha512-rNvtEm7Axzj18neIk0C8kjr1ZXbJsHkWDqGedCfOiLVBjSCxWBcbJ26/I7g9owoeGKUoyrOgs73cIk7WxLd9qA==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-7.2.3.tgz", + "integrity": "sha512-eRIo5XuQAJrubo4514gEnmREKI35045LItjucOEK/YNQYj3LhEpYEbBdqjlu/wmd9Rcqp2c3GJ4ynFoEqby3sg==", + "license": "MIT", + "dependencies": { + "@azure/msal-common": "16.17.0", + "jsonwebtoken": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@azure/storage-blob": { "version": "12.34.0", "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.34.0.tgz", @@ -4197,6 +4339,12 @@ "tslib": "^2.8.0" } }, + "node_modules/@tediousjs/connection-string": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@tediousjs/connection-string/-/connection-string-1.1.3.tgz", + "integrity": "sha512-9ZCb//U/Ua1XCDRPyeGPUXG5HGHpoq/6QxPv79q17ntBD5YeEGBQ0q2WlAfr9YvYOkcMRAXFUNY/qfJ6dheWDg==", + "license": "MIT" + }, "node_modules/@tokenizer/inflate": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.4.1.tgz", @@ -4297,6 +4445,18 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/mssql": { + "version": "12.3.2", + "resolved": "https://registry.npmjs.org/@types/mssql/-/mssql-12.3.2.tgz", + "integrity": "sha512-p3t4s6jfQETfbDMxOI3If81MefZ5njRiLV+Q7ikZ+iw/u6skoNQH2TNYnnXnHd40/cs/fToS0bnRPY+Rxg332A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "tarn": "^3.0.1", + "tedious": "*" + } + }, "node_modules/@types/node": { "version": "26.6.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.11.tgz", @@ -4351,6 +4511,15 @@ "@types/react": "*" } }, + "node_modules/@types/readable-stream": { + "version": "4.0.25", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.25.tgz", + "integrity": "sha512-7GsxL8Wd5X3jh73/qgW7WCnbBvGSdD8U3E4Jiuus3/8I+PN20DtlkJtwFhr/sImXfDDQ2Z03i/9wNiIF3TVSsw==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/send": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", @@ -4979,6 +5148,15 @@ "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", "license": "MIT" }, + "node_modules/aws-ssl-profiles": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", + "integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.17", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.17.tgz", @@ -5183,6 +5361,18 @@ "node": ">=0.6" } }, + "node_modules/bl": { + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/bl/-/bl-6.1.6.tgz", + "integrity": "sha512-jLsPgN/YSvPUg9UX0Kd73CXpm2Psg9FxMeCSXnk3WBO3CMT10JMwijubhGfHCnFu6TPn1ei3b975dxv7K2pWVg==", + "license": "MIT", + "dependencies": { + "@types/readable-stream": "^4.0.0", + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^4.2.0" + } + }, "node_modules/body-parser": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", @@ -5316,12 +5506,57 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "license": "MIT" }, + "node_modules/bundle-name": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.1.tgz", + "integrity": "sha512-DdH81/zPLVS11EUgWq3tEu/xn+EzljlMYooDNdzWEnFha3R3NBMpMV1UqYIpjYHV/SgpFKMIX1Oh7o06SjM/oA==", + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -5803,6 +6038,34 @@ } } }, + "node_modules/default-browser": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.1.tgz", + "integrity": "sha512-m1pAzaJgZ/gssEqlOhJkPJp8Xly7QyW6xcrkUa2KKcDeDSEMP7X8xipU3snUcfisTQx0w1AGae+9UtJSfVnXGw==", + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -5927,6 +6190,15 @@ "node": ">= 0.4" } }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -7069,6 +7341,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/generate-function": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", + "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", + "license": "MIT", + "dependencies": { + "is-property": "^1.0.2" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -7392,6 +7673,51 @@ "node": ">=8" } }, + "node_modules/is-in-ssh": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz", + "integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container/node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -7416,6 +7742,12 @@ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", "license": "MIT" }, + "node_modules/is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==", + "license": "MIT" + }, "node_modules/is-unsafe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.3.tgz", @@ -7555,6 +7887,12 @@ "url": "https://github.com/sponsors/panva" } }, + "node_modules/js-md4": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/js-md4/-/js-md4-0.3.2.tgz", + "integrity": "sha512-/GDnfQYsltsjRswQhN9fhv3EMw2sCpUdrdxyWDOUK7eyD++r3gRhzgiQgc/x4MAv2i1iuQ4lxO5mvqM3vj4bwA==", + "license": "MIT" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -7619,6 +7957,49 @@ "node": ">=6" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "node_modules/jwt-decode": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", @@ -7929,6 +8310,48 @@ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "license": "MIT" }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, "node_modules/lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -8009,6 +8432,12 @@ "node": ">=4" } }, + "node_modules/long": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", + "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", + "license": "Apache-2.0" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -8030,6 +8459,21 @@ "yallist": "^3.0.2" } }, + "node_modules/lru.min": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.5.tgz", + "integrity": "sha512-5J9ysMYUpYIg9RF2vJpy9SinEmSviFSe0GyPpCQ4L5QSkLAgeLXlTAOu2ZwWUU5m+0SBl6gUU1R1ZQB3aKypfA==", + "license": "MIT", + "engines": { + "bun": ">=1.0.0", + "deno": ">=1.30.0", + "node": ">=8.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wellwelwel" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -8563,6 +9007,34 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/mssql": { + "version": "12.8.3", + "resolved": "https://registry.npmjs.org/mssql/-/mssql-12.8.3.tgz", + "integrity": "sha512-+EZw4G9YjxMusECzBMs8tcMHEcHSstW5HhiRhi7UpUHUA5nnJgK6sg0pTeUHFo+1pZzXnT6ROfDn6DAyE3KHaA==", + "license": "MIT", + "dependencies": { + "@tediousjs/connection-string": "^1.1.2", + "commander": "^11.0.0", + "debug": "^4.3.3", + "tarn": "^3.0.2", + "tedious": "^19.2.2 || ^20.0.0" + }, + "bin": { + "mssql": "bin/mssql" + }, + "engines": { + "node": ">=18.19.0" + } + }, + "node_modules/mssql/node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "license": "MIT", + "engines": { + "node": ">=16" + } + }, "node_modules/multer": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz", @@ -8609,6 +9081,39 @@ "integrity": "sha512-5e2ayy9RjixFisCSfPL6pOgCJhDXYLLx73puYEnIT05A60q3kw3q0ipnqcCgmg6EAScLwatGMBJEHYmP7BSEYw==", "license": "MIT" }, + "node_modules/mysql2": { + "version": "3.24.6", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz", + "integrity": "sha512-enu73KhbAua2L3dIxjc6qg6ZJ7H3pt1BImZASWNWY5xSsmJ1ZuUPULTDGXgmJbI61vb+nJAG19IZclIq19UidQ==", + "license": "MIT", + "dependencies": { + "aws-ssl-profiles": "^1.1.2", + "generate-function": "^2.3.1", + "iconv-lite": "^0.7.3", + "long": "^5.3.2", + "lru.min": "^1.1.4", + "named-placeholders": "^1.1.6", + "sql-escaper": "^1.5.1" + }, + "engines": { + "node": ">= 8.0" + }, + "peerDependencies": { + "@types/node": ">= 8" + } + }, + "node_modules/named-placeholders": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.6.tgz", + "integrity": "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==", + "license": "MIT", + "dependencies": { + "lru.min": "^1.1.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/nanoid": { "version": "3.3.20", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", @@ -8627,6 +9132,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/native-duplexpair": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/native-duplexpair/-/native-duplexpair-1.0.0.tgz", + "integrity": "sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==", + "license": "MIT" + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -9274,6 +9785,18 @@ "node": ">=0.10.0" } }, + "node_modules/powershell-utils": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.1.tgz", + "integrity": "sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -9309,6 +9832,15 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -9719,6 +10251,22 @@ "node": ">=0.10.0" } }, + "node_modules/readable-stream": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.8.0.tgz", + "integrity": "sha512-2jhTTU3Eilp/2DMT71gbcoqC35eQHasMJH0RHkYxwlxIv3+FR6Y5xAFZIwEGLxKkjZYEFlsiMNIdwUqjK2lLHQ==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/reflect-metadata": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", @@ -9871,6 +10419,18 @@ "url": "https://opencollective.com/express" } }, + "node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/rxjs": { "version": "7.8.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", @@ -10330,6 +10890,21 @@ "node": ">= 10.x" } }, + "node_modules/sql-escaper": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/sql-escaper/-/sql-escaper-1.9.1.tgz", + "integrity": "sha512-4p522TVYaJXTbMlYgAwacjyg3EJyYe9KYWYlYJVwZG1YjtzxU5m5iSzsZoGI69Po7j3i/2tKlpZQi7uvhTL+WA==", + "license": "MIT", + "engines": { + "bun": ">=1.0.0", + "deno": ">=2.0.0", + "node": ">=12.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/mysqljs/sql-escaper?sponsor=1" + } + }, "node_modules/stackframe": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", @@ -10380,6 +10955,15 @@ "node": ">=10.0.0" } }, + "node_modules/string_decoder": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.4.0.tgz", + "integrity": "sha512-r8azg21Y67ckRmeG0hHol5CeDXMs4ZFkFT6eXMO39hX7khvJcopBcYTCeWZ0rQXkMoPh8lVdbjmsOMGL8krxRQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -10530,6 +11114,34 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tarn": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.1.2.tgz", + "integrity": "sha512-3RTvqKZcK/17jnJ8rMKFXbyNogywTs1z0gVPPwFsJGX46rkmUHOdIaSQ/aVO1rS7nH+soiXiWk7rvUXxndm8Dg==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/tedious": { + "version": "20.4.3", + "resolved": "https://registry.npmjs.org/tedious/-/tedious-20.4.3.tgz", + "integrity": "sha512-ivH+3CjagU2fndrUeqKsWH5n8SOhyn74RYYTL8Rjcgz/4Sbvqjj/zcg5mpTAmOYnXxr0+59nQShv0HMmMaSQZA==", + "license": "MIT", + "dependencies": { + "@azure/core-auth": "^1.10.1", + "@azure/identity": "^4.14.1", + "@azure/keyvault-keys": "^4.10.2", + "@types/node": ">=22", + "bl": "^6.1.4", + "iconv-lite": "^0.7.0", + "js-md4": "^0.3.2", + "native-duplexpair": "^1.0.0" + }, + "engines": { + "node": ">=22" + } + }, "node_modules/terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -11015,6 +11627,37 @@ } } }, + "node_modules/wsl-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-1.0.1.tgz", + "integrity": "sha512-c16PKLIRxBYpR3jSWsdS7SFp0COm5SOQdiFjY818dYFHJbMGuLBszpF07LBWmOS1uzrHa9VGdynsEgoeKy0oOQ==", + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0", + "powershell-utils": "^0.2.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/wsl-utils/node_modules/is-wsl": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/xcode": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xcode/-/xcode-4.0.0.tgz", diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index a0c3ace..c810d23 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -197,6 +197,8 @@ export interface Member { units?: Units; // overrides the site default compTier?: Tier; // granted by an admin; billing never drops a member below it identityHashes?: string[]; // HMACs of "apple:" / "google:" for social sign-in + /** Set on members brought over from an old site: which source systems and when. */ + imported?: { sources: string[]; at: string }; createdAt: string; lastActiveAt: string; } From 8f321858334953df6245444432f714e344057bdf Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:08:45 +0000 Subject: [PATCH 2/4] Import members workflow: set the work folder in a step (runner context isn't allowed in job env) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvNyMo8QQFmyaDpp8vc --- .github/workflows/import.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml index 5d15ddb..f2fd2e5 100644 --- a/.github/workflows/import.yml +++ b/.github/workflows/import.yml @@ -61,13 +61,13 @@ jobs: LEGACY: ${{ inputs.legacy_backup }} SKADATE: ${{ inputs.skadate_dump }} SKAPHOTOS: ${{ inputs.skadate_photos }} - WORK: ${{ runner.temp }}/import PREFIX: bundles/${{ inputs.site }}-${{ github.run_id }} steps: - uses: actions/checkout@v4 - name: Check inputs run: | + echo "WORK=$RUNNER_TEMP/import" >> "$GITHUB_ENV" if [ "$MODE" != remove ] && [ -z "$LEGACY$SKADATE" ]; then echo "Give a legacy backup and/or a SkaDate dump."; exit 1; fi if [ -n "$SKADATE$SKAPHOTOS" ] && [ "$SITE" != afterh ]; then echo "SkaDate files belong to AfterH only."; exit 1; fi From ac8c0f44b594c0d26544f3da9896231a3e82e938 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:24:35 +0000 Subject: [PATCH 3/4] Import workflow: print the counts-only report in the job log too Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvNyMo8QQFmyaDpp8vc --- .github/workflows/import.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml index f2fd2e5..5dd2555 100644 --- a/.github/workflows/import.yml +++ b/.github/workflows/import.yml @@ -167,6 +167,7 @@ jobs: done [ "$status" = "Succeeded" ] || exit 1 az storage blob download --auth-mode key -c imports -n "$report" -f "$RUNNER_TEMP/report.json" -o none + echo "Report (counts only):"; cat "$RUNNER_TEMP/report.json" { echo "### $MODE: $SITE on $ENV" echo '```json'; cat "$RUNNER_TEMP/report.json"; echo '```' From 638681ef5a9a247255e121234fb14b95f5e21a2c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 02:59:38 +0000 Subject: [PATCH 4/4] Import: hide SkaDate's made-up usernames, and let dead signups be flagged, suspended or removed SkaDate generated names like "h6jm" at signup; imported members with one now pick a name at first sign-in (a name chosen on the older AfterH site wins). Signups that never used the old site are spotted from several signs and handled by the new dead_signups workflow input. Admin shows "No name yet" for members without a name. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015x8UvNyMo8QQFmyaDpp8vc --- .github/workflows/import.yml | 10 ++++++-- apps/api/scripts/import.ts | 4 ++- apps/api/src/import/bundle.ts | 5 +++- apps/api/src/import/load.ts | 32 ++++++++++++++++++++---- apps/api/src/import/map.ts | 7 ++++++ apps/api/src/import/skadate.ts | 20 ++++++++++++--- apps/api/test/import.test.ts | 38 ++++++++++++++++++++++++++++- apps/member/src/app/admin/index.tsx | 6 ++--- infra/import-members.md | 8 +++++- 9 files changed, 113 insertions(+), 17 deletions(-) diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml index 5dd2555..76f5d0e 100644 --- a/.github/workflows/import.yml +++ b/.github/workflows/import.yml @@ -35,6 +35,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 @@ -61,6 +66,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 @@ -150,8 +156,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") ;; esac # The job reads (and deletes) this file, so its own settings and secrets stay untouched. diff --git a/apps/api/scripts/import.ts b/apps/api/scripts/import.ts index 296858a..85123e5 100644 --- a/apps/api/scripts/import.ts +++ b/apps/api/scripts/import.ts @@ -131,6 +131,8 @@ async function argsFromBlob(): Promise { }; try { if (cmd === 'load') { + 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; } @@ -142,7 +144,7 @@ async function argsFromBlob(): Promise { const bundles = []; for (const d of dirs) bundles.push(await readBundle(d)); const report = await loadBundles(bundles, { - site, repo, crypto: new SiteCrypto(keyProvider(), site.id), geo: new WorldGeo(), photos, now: new Date(), dryRun, + site, repo, crypto: new SiteCrypto(keyProvider(), site.id), geo: new WorldGeo(), photos, now: new Date(), dryRun, deadSignups, }); await output(report); } else if (cmd === 'remove') { diff --git a/apps/api/src/import/bundle.ts b/apps/api/src/import/bundle.ts index 2f430cf..b5ded46 100644 --- a/apps/api/src/import/bundle.ts +++ b/apps/api/src/import/bundle.ts @@ -30,6 +30,8 @@ export interface SrcMember { key: string; // ":", 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 @@ -40,7 +42,8 @@ export interface SrcMember { fields: Record; 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[]; } diff --git a/apps/api/src/import/load.ts b/apps/api/src/import/load.ts index 601bb3c..3c5c9be 100644 --- a/apps/api/src/import/load.ts +++ b/apps/api/src/import/load.ts @@ -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); cur.photos.push(...photos); } } @@ -110,6 +115,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 { @@ -155,6 +162,20 @@ export async function loadBundles(bundles: Bundle[], d: LoadDeps): Promise(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>(); 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 }); @@ -56,6 +56,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(); @@ -84,10 +86,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, diff --git a/apps/api/test/import.test.ts b/apps/api/test/import.test.ts index 92884db..32468aa 100644 --- a/apps/api/test/import.test.ts +++ b/apps/api/test/import.test.ts @@ -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'; @@ -100,3 +100,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 +}); diff --git a/apps/member/src/app/admin/index.tsx b/apps/member/src/app/admin/index.tsx index 342f744..cae7750 100644 --- a/apps/member/src/app/admin/index.tsx +++ b/apps/member/src/app/admin/index.tsx @@ -467,9 +467,9 @@ function Members({ api, siteId }: { api: AdminApi; siteId: string }) { {data.rows.map((m, idx) => ( - setOpenId(m.id)} accessibilityRole="button" accessibilityLabel={`View ${m.displayName}'s profile`}> + setOpenId(m.id)} accessibilityRole="button" accessibilityLabel={`View ${m.displayName || 'this member'}'s profile`}> - {m.displayName}{m.age ? `, ${m.age}` : ''} + {m.displayName || 'No name yet'}{m.age ? `, ${m.age}` : ''} {m.tier !== 'free' ? : null} {m.status === 'suspended' ? : null} {m.reports ? 1 ? 's' : ''}`} tone="alert" /> : null} @@ -516,7 +516,7 @@ function MemberProfilePanel({ api, siteId, memberId, onClose }: { api: AdminApi; - {p ? `${p.displayName}${p.age ? `, ${p.age}` : ''}` : 'Profile'} + {p ? `${p.displayName || 'No name yet'}${p.age ? `, ${p.age}` : ''}` : 'Profile'} diff --git a/infra/import-members.md b/infra/import-members.md index 56e5a96..563ce26 100644 --- a/infra/import-members.md +++ b/infra/import-members.md @@ -53,7 +53,7 @@ Note that the dev "Load demo data" deploy option wipes all member data on dev, i | Old site | New platform | |---|---| -| Username | Display name (real names are not carried over) | +| Username | Display name (real names are not carried over). SkaDate made up names like "h6jm" at signup; those are not shown, and the member picks a name at first sign-in (a name they chose on the older site wins) | | Email | Sign-in email (stored only as a keyed hash plus site-key encryption) | | Gender / looking for | Gender / looking for. Couples: not supported yet, left behind | | Birth date | Birth year (missing or under 18: asked at first sign-in) | @@ -70,6 +70,12 @@ Note that the dev "Load demo data" deploy option wipes all member data on dev, i | Photos approved on the old site | Approved. Unapproved or explicit ones wait in moderation (explicit ones as private, since explicit photos are off on these sites) | | Interests (winks), favourites, blocks, profile views, private photo access, mailbox messages | Likes, favorites, blocks, views, granted private access, messages | +**Dead signups** (SkaDate): accounts with three or more of: email never verified, gone within an hour of +joining, never sent a message, no photo, not approved, almost no profile answers. The workflow's +`dead_signups` input decides: `flag` (moderation item, the default), `suspend`, or `remove` (left out, +and removed if an earlier run brought them in). Someone who used either old AfterH system is never a dead signup. +AfterH was loaded with `remove` (Jeff, Nov 29). + Every member starts on the Free tier (the paywall is off at launch). Imported members with contact details in "About me", or flagged on the old site (spam suspected, not approved, suspended), get a moderation item so the site owner can look.