MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / updateModel

Function updateModel

apps/web/src/lib/integrations/slack-service.ts:443–481  ·  view source on GitHub ↗
(
  owner: Owner,
  modelSlug: string
)

Source from the content-addressed store, hash-verified

441 */
442export async function readSlackBotToken(
443 integration: PlatformIntegration
444): Promise<SlackBotTokenRead> {
445 const owner = getOwnerFromInstallation(integration);
446 if (!owner) {
447 // Terminal for this read path: re-reading the same row cannot produce an owner.
448 captureException(new Error('Slack integration has no exclusive owner'), {
449 level: 'error',
450 tags: { component: 'slack-service', op: 'read-slack-credential' },
451 extra: { integrationId: integration.id },
452 });
453 return { status: 'unavailable', reason: 'owner_missing' };
454 }
455
456 let credential: SlackOAuthCredential | null;
457 try {
458 credential = await getSlackCredentialByIntegrationId(integration.id);
459 } catch (error) {
460 captureException(error, {
461 level: 'error',
462 tags: { component: 'slack-service', op: 'read-slack-credential' },
463 extra: { integrationId: integration.id },
464 });
465 return { status: 'unavailable', reason: 'read_failed' };
466 }
467 if (!credential) return { status: 'absent' };
468
469 try {
470 // A revoked row decrypts to null: Slack already dropped that token, so nothing
471 // is live and the row is safe to remove.
472 const token = decryptSlackBotToken(credential, owner);
473 if (!token) return { status: 'absent' };
474 return { status: 'available', token };
475 } catch (error) {
476 captureException(error, {
477 level: 'error',
478 tags: { component: 'slack-service', op: 'read-slack-credential' },
479 extra: {
480 integrationId: integration.id,
481 kind: error instanceof SlackCredentialDecryptionError ? error.kind : 'unknown',
482 },
483 });
484 return { status: 'unavailable', reason: 'decrypt_failed' };

Callers

nothing calls this directly

Calls 8

getOrganizationByIdFunction · 0.90
isAllowedFunction · 0.85
getInstallationFunction · 0.70
setMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected