From cb43deead1e0510d747dabb0645544263ee9a7d9 Mon Sep 17 00:00:00 2001 From: Tynan Purdy Date: Sun, 14 Jun 2026 16:50:51 -0400 Subject: [PATCH] fix to serve email in profile after fetching via xrpc --- gateway/src/services/oauth.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gateway/src/services/oauth.ts b/gateway/src/services/oauth.ts index a1f57ee..2f1ff31 100644 --- a/gateway/src/services/oauth.ts +++ b/gateway/src/services/oauth.ts @@ -195,9 +195,22 @@ export class OAuthService { // Fall back to DID } - const email = (session as unknown as Record).email as - | string - | undefined; + // Fetch email from PDS via com.atproto.server.getSession (requires account:email scope) + let email: string | undefined; + try { + const sessionRes = await session.fetchHandler( + "/xrpc/com.atproto.server.getSession", + ); + if (sessionRes.ok) { + const data = (await sessionRes.json()) as { + email?: string; + emailConfirmed?: boolean; + }; + email = data.email; + } + } catch { + // PDS may not support or may deny email access; continue without it + } return { did, handle, email }; } -- 2.51.2