(workspaceId: string)
| 585 | * ambiguity: never tear down on uncertainty. |
| 586 | */ |
| 587 | export async function hasWorkspaceInboxGraceAccess(workspaceId: string): Promise<boolean> { |
| 588 | try { |
| 589 | if (isInboxEnabled) return true |
| 590 | if (!isBillingEnabled) return true |
| 591 | |
| 592 | const { getWorkspaceWithOwner } = await import('@/lib/workspaces/permissions/utils') |
| 593 | const ws = await getWorkspaceWithOwner(workspaceId, { includeArchived: true }) |
| 594 | if (!ws) return true |
| 595 | |
| 596 | if (ws.organizationId) { |
| 597 | const { getOrganizationSubscription } = await import('@/lib/billing/core/billing') |
| 598 | const orgSub = await getOrganizationSubscription(ws.organizationId) |
| 599 | return !!orgSub && isInboxEntitledPlan(orgSub.plan) |
| 600 | } |
| 601 | |
| 602 | const billedSub = await getHighestPrioritySubscription(ws.billedAccountUserId) |
| 603 | return !!billedSub && isInboxEntitledPlan(billedSub.plan) |
| 604 | } catch (error) { |
| 605 | logger.error('Error checking workspace inbox grace access', { error, workspaceId }) |
| 606 | return true |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Check if user has access to live sync (every 5 minutes) for KB connectors |
no test coverage detected