Fix username resolver: use www.reddit.com, not api.reddit.com

api.reddit.com/api/user_data_by_account_ids returns 404 without an
OAuth token — which is why every chat in the dashboard sat on
t2_xxx or unknown. The same path on www.reddit.com (with a .json
suffix) is served unauthenticated and returns the expected user
map. Switch the resolver to that host so enrichUsernames actually
succeeds.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jjbruntonandClaude Opus 4.7 committed 2026-05-22 23:30:01 +01:00
1 parent 01ea8fd36b
commit cf7fc41761
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -208,7 +208,9 @@ export async function bootstrap(config: Config, logger: Logger): Promise<AppCont
const chunk = ids.slice(i, i + 100).join(',');
try {
const res = await fetchWithTimeout(
`https://api.reddit.com/api/user_data_by_account_ids?ids=${encodeURIComponent(chunk)}`,
// www.reddit.com serves this unauthenticated; the api.reddit.com
// host 404s the same path without an OAuth token.
`https://www.reddit.com/api/user_data_by_account_ids.json?ids=${encodeURIComponent(chunk)}`,
{ headers: { 'User-Agent': config.reddit.userAgent }, timeoutMs: 15_000 },
);
if (!res.ok) {
+3 -1
View File
@@ -1066,7 +1066,8 @@ export class ChatService {
}
}
// Pass 3 — for every chat still on a raw t2 ID, call the resolver.
// Pass 3 — for every chat still on a raw t2 ID, batch-resolve via the
// injected resolver (www.reddit.com/api/user_data_by_account_ids.json).
const needed: string[] = [];
for (const chat of this.cache.get()) {
const t2 = this.extractT2(chat);
@@ -1078,6 +1079,7 @@ export class ChatService {
let updated = 0;
for (const [t2, name] of Object.entries(got)) {
const bare = t2.replace(/^t2_/, '');
if (!name) continue;
this.t2ToUsername.set(bare, name);
this.persistUsername(t2, name);
for (const chat of this.cache.get()) {