MCPcopy Index your code
hub / github.com/simstudioai/sim / getCredentialOwner

Function getCredentialOwner

apps/sim/app/api/cron/renew-subscriptions/route.ts:19–36  ·  view source on GitHub ↗
(
  credentialId: string
)

Source from the content-addressed store, hash-verified

17const LOCK_TTL_SECONDS = 300
18
19async 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.

Callers 1

Calls 3

resolveOAuthAccountIdFunction · 0.90
errorMethod · 0.80
eqFunction · 0.50

Tested by

no test coverage detected