Events 3.6.0, Accounts 1.5.0, contracts 1.14.0: the nightly people check
- Contracts 1.14.0: people.check in crosscode.identity-request/1 (500 subs) and its reply (active / deactivated / deleted / unknown, profile for the first two). - Accounts 1.5.0: answers people.check with profiles only for people the product knows; the reply isn't stored. - Events 3.6.0: accounts-people-check job (04:30): fixes out-of-date copies, handles deleted accounts as user.deleted, counts unknown people and stops (changing nothing) when most of a page is unknown; skipped with an Accounts older than 1.5.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@ import { newAccountEmail, testEmail } from '../lib/emails.js';
|
||||
import { hashToken, randomToken } from '../lib/crypto.js';
|
||||
import { appVersion } from '../lib/version.js';
|
||||
import { BUILT_IN_VERSION } from '../privacy/notice.js';
|
||||
import { emailProblem, normaliseEmail, profileChanged, setNewsConsent } from '../accounts/service.js';
|
||||
import { emailProblem, normaliseEmail, profileChanged, profileOf, setNewsConsent } from '../accounts/service.js';
|
||||
import { turnOff } from '../accounts/twoFactor.js';
|
||||
import { signOutEverywhere } from '../oidc/sessions.js';
|
||||
import { anonymise } from '../privacy/deletion.js';
|
||||
@@ -303,6 +303,22 @@ async function handle(ctx: Ctx, provider: Provider, link: ProductLink, secret: s
|
||||
await logRequest(ctx, link, r, 'demo_people_removed_by_product', null, req, { removed, kept: kept.length });
|
||||
return reply({ removed, kept });
|
||||
}
|
||||
case 'people.check': {
|
||||
// 1.5.0: the product's regular check that its copies are current. Profiles only for people
|
||||
// this product knows; a deleted account is said to be deleted (its sub was that person's).
|
||||
const subs = [...new Set(r.subs)];
|
||||
const known = new Set((await ctx.db.productPerson.findMany({ where: { linkId: link.installId, accountId: { in: subs } }, select: { accountId: true } })).map((p) => p.accountId));
|
||||
const accounts = new Map((await ctx.db.account.findMany({ where: { id: { in: subs } } })).map((a) => [a.id, a]));
|
||||
const people = subs.map((sub) => {
|
||||
const a = accounts.get(sub);
|
||||
if (a?.status === 'deleted') return { sub, status: 'deleted' as const, profile: null };
|
||||
if (!a || !known.has(sub)) return { sub, status: 'unknown' as const, profile: null };
|
||||
return { sub, status: a.status === 'deactivated' ? 'deactivated' as const : 'active' as const, profile: profileOf(a) };
|
||||
});
|
||||
const count = (s: string) => people.filter((p) => p.status === s).length;
|
||||
await logRequest(ctx, link, r, 'people_checked_by_product', null, req, { checked: people.length, deleted: count('deleted'), unknown: count('unknown') });
|
||||
return reply({ people });
|
||||
}
|
||||
case 'church.branding': {
|
||||
const changed = await applyLook(ctx, r.church, r.overwrite);
|
||||
await logRequest(ctx, link, r, 'church_look_from_product', null, req, { changed, overwrite: r.overwrite });
|
||||
@@ -382,7 +398,8 @@ export function requestsRouter(ctx: Ctx, provider: Provider) {
|
||||
}
|
||||
const out = await handle(ctx, provider, link, secret, request, req);
|
||||
// Checks write nothing, so they needn't be remembered.
|
||||
const isCheck = 'check' in request && request.check;
|
||||
// people.check (1.5.0) only reads, and its reply holds profiles: never kept.
|
||||
const isCheck = ('check' in request && request.check) || request.type === 'people.check';
|
||||
if (!isCheck) {
|
||||
await ctx.db.productRequest.create({ data: { requestId: request.requestId, linkId: link.installId, type: request.type, reply: out as never, createdAt: ctx.now() } }).catch(() => {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user