( credentialId: string )
| 17 | const LOCK_TTL_SECONDS = 300 |
| 18 | |
| 19 | async function getCredentialOwner( |
| 20 | credentialId: string |
| 21 | ): Promise<{ userId: string; accountId: string } | null> { |
| 22 | const resolved = await resolveOAuthAccountId(credentialId) |
| 23 | if (!resolved) { |
| 24 | logger.error(`Failed to resolve OAuth account for credential ${credentialId}`) |
| 25 | return null |
| 26 | } |
| 27 | const [credentialRecord] = await db |
| 28 | .select({ userId: account.userId }) |
| 29 | .from(account) |
| 30 | .where(eq(account.id, resolved.accountId)) |
| 31 | .limit(1) |
| 32 | |
| 33 | return credentialRecord |
| 34 | ? { userId: credentialRecord.userId, accountId: resolved.accountId } |
| 35 | : null |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Renews Microsoft Teams chat subscriptions that are close to expiring. |
no test coverage detected