Skip to content

Commit e21aba2

Browse files
feat(api): roster rows carry origin, GitHub facts, Slack SSO, bounces, signals
Row-local signals (never-signed-in, no-avatar, no-bio, bio links, email/name mismatch, bounced email, GitHub gone/new/inactive) count toward an attention score; positives (slack-sso, has-footprint) are informational. Linked accounts on the requested page are re-probed against GitHub when their record is older than a day, with bounded concurrency and a failure-keeps-old-record rule. New origin filter. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ
1 parent 706636c commit e21aba2

5 files changed

Lines changed: 478 additions & 49 deletions

File tree

‎apps/api/src/plugins/services.ts‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { TagWriteService } from '../services/tag.write.js';
2929
import { GitHubAccountService } from '../services/github-account.js';
3030
import { AccountClaimService } from '../services/account-claim.js';
3131
import { ModerationService, ModerationWriteService } from '../services/moderation.js';
32+
import { probeGitHubUser } from '../auth/github-client.js';
3233
import { LoggingNotifier, type Notifier } from '../notify/index.js';
3334
import { EmailNotifier } from '../notify/email-notifier.js';
3435
import { PostmarkTransport } from '../notify/postmark-transport.js';
@@ -110,15 +111,36 @@ async function servicesPlugin(fastify: FastifyInstance): Promise<void> {
110111
tagsWrite: new TagWriteService(state),
111112
githubAccount,
112113
accountClaim: new AccountClaimService(state, fastify.store.private, githubAccount),
113-
moderation: new ModerationService(state, fastify.store.private, (personId) => {
114-
// Newest sign-in from session metadata; the auth plugin decorates it
115-
// after this one registers, so resolve lazily per call.
116-
let latest: string | null = null;
117-
for (const m of fastify.sessionMetadata?.getAll(personId) ?? []) {
118-
if (!latest || m.issuedAt > latest) latest = m.issuedAt;
119-
}
120-
return latest;
121-
}),
114+
moderation: new ModerationService(
115+
state,
116+
fastify.store.private,
117+
(personId) => {
118+
// Session facts from session metadata; the auth plugin decorates it
119+
// after this one registers, so resolve lazily per call.
120+
let latest: string | null = null;
121+
let count = 0;
122+
for (const m of fastify.sessionMetadata?.getAll(personId) ?? []) {
123+
count += 1;
124+
if (!latest || m.issuedAt > latest) latest = m.issuedAt;
125+
}
126+
return { lastLoginAt: latest, count };
127+
},
128+
{
129+
log: fastify.log,
130+
// The roster re-checks linked GitHub accounts against the API using the
131+
// OAuth app's client credentials; without them the probe is simply off.
132+
...(fastify.config.GITHUB_OAUTH_CLIENT_ID && fastify.config.GITHUB_OAUTH_CLIENT_SECRET
133+
? {
134+
probe: (githubUserId: number) =>
135+
probeGitHubUser(
136+
githubUserId,
137+
fastify.config.GITHUB_OAUTH_CLIENT_ID as string,
138+
fastify.config.GITHUB_OAUTH_CLIENT_SECRET as string,
139+
),
140+
}
141+
: {}),
142+
},
143+
),
122144
moderationWrite: new ModerationWriteService(state),
123145
});
124146
}

‎apps/api/src/routes/moderation.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ok, paginated } from '../lib/response.js';
1313
import { ApiNotFoundError, ApiValidationError } from '../lib/errors.js';
1414
import { getCallerSession } from '../services/permissions.js';
1515
import { buildTransactionOptions } from '../store/commit-meta.js';
16-
import type { VoteFilter } from '../services/moderation.js';
16+
import type { MemberOrigin, VoteFilter } from '../services/moderation.js';
1717

1818
function requireStaffOr404(request: FastifyRequest): void {
1919
const level = request.session.accountLevel;
@@ -34,6 +34,7 @@ export async function moderationRoutes(fastify: FastifyInstance): Promise<void>
3434
properties: {
3535
q: { type: 'string' },
3636
vote: { type: 'string', enum: ['none', 'spam', 'legit'] },
37+
origin: { type: 'string', enum: ['imported', 'signed-up'] },
3738
joinedAfter: { type: 'string' },
3839
joinedBefore: { type: 'string' },
3940
includeDeactivated: { type: 'boolean' },
@@ -51,6 +52,7 @@ export async function moderationRoutes(fastify: FastifyInstance): Promise<void>
5152
const result = await fastify.services.moderation.listMembers({
5253
q: q['q'] as string | undefined,
5354
vote: q['vote'] as VoteFilter | undefined,
55+
origin: q['origin'] as MemberOrigin | undefined,
5456
joinedAfter: q['joinedAfter'] as string | undefined,
5557
joinedBefore: q['joinedBefore'] as string | undefined,
5658
includeDeactivated: q['includeDeactivated'] as boolean | undefined,

0 commit comments

Comments
 (0)