MCPcopy
hub / github.com/CodebuffAI/codebuff / ensureActiveBlockGrant

Function ensureActiveBlockGrant

packages/billing/src/subscription.ts:400–423  ·  view source on GitHub ↗
(params: {
  userId: string
  subscription: SubscriptionRow
  logger: Logger
})

Source from the content-addressed store, hash-verified

398}
399
400export async function ensureActiveBlockGrant(params: {
401 userId: string
402 subscription: SubscriptionRow
403 logger: Logger
404}): Promise<BlockGrantResult> {
405 const { userId, subscription, logger } = params
406 const subscriptionId = subscription.stripe_subscription_id
407
408 const { result } = await withAdvisoryLockTransaction({
409 callback: async (tx) => {
410 return ensureActiveBlockGrantCallback({
411 conn: tx,
412 userId,
413 subscription,
414 logger,
415 })
416 },
417 lockKey: `user:${userId}`,
418 context: { userId, subscriptionId },
419 logger,
420 })
421
422 return result
423}
424
425/**
426 * Combined function that gets the active subscription and ensures a block grant exists.

Callers 1

Calls 2

Tested by

no test coverage detected