( owner: Owner, modelSlug: string )
| 530 | if ( |
| 531 | isActive && |
| 532 | (options.getChatSdkAccessToken || |
| 533 | options.deleteChatSdkInstallation || |
| 534 | options.deleteChatSdkIdentityCache) |
| 535 | ) { |
| 536 | if (!organizationId) { |
| 537 | throw new TRPCError({ |
| 538 | code: 'INTERNAL_SERVER_ERROR', |
| 539 | message: 'Linear installation is missing an organization ID', |
| 540 | }); |
| 541 | } |
| 542 | |
| 543 | // Fetch the access token from the chat-sdk adapter BEFORE deleting the |
| 544 | // installation, then ask Linear to revoke it. This ensures the OAuth app |
| 545 | // is properly uninstalled on Linear's side; otherwise the workspace will |
| 546 | // see "already installed" on a reinstall attempt. |
| 547 | const accessToken = await options.getChatSdkAccessToken?.(organizationId); |
| 548 | if (accessToken) { |
| 549 | await revokeLinearToken(accessToken); |
| 550 | } |
| 551 | |
| 552 | await options.deleteChatSdkInstallation?.(organizationId); |
| 553 | await options.deleteChatSdkIdentityCache?.(organizationId); |
| 554 | } |
| 555 | |
| 556 | await db.delete(platform_integrations).where(eq(platform_integrations.id, integration.id)); |
| 557 | |
| 558 | return { success: true }; |
| 559 | } |
| 560 | |
| 561 | export async function deleteInstallationByOrganizationId(organizationId: string) { |
| 562 | const integration = await getInstallationByOrganizationId(organizationId); |
| 563 | |
| 564 | if (!integration) { |
| 565 | return { success: true, deleted: false }; |
| 566 | } |
| 567 | |
| 568 | await db.delete(platform_integrations).where(eq(platform_integrations.id, integration.id)); |
| 569 | |
| 570 | return { success: true, deleted: true }; |
| 571 | } |
| 572 |
nothing calls this directly
no test coverage detected