- Порезанный
- 24 апреля 2026 г. в 22:36 UTC
- Автор
- Kamo
- Обещать
- 5d98d8a
Core model change: one org → many VoipProviderInstances (was: one per org). Every provider API call is now instance-scoped. PhoneProvider interface: - New methods for extension/user/device CRUD + voicemail audio/transcription. - New capability flags (extensionManagement, userManagement, deviceManagement, voicemailTranscription). Defaults throw **************** (HTTP 501) so stub providers don't break. Frontend checks getCapabilities() to hide/disable actions per provider. - ProviderException (HTTP 502) for external-dependency failures. PhoneProviderFactory: - getInstance(UUID) / **************** replace legacy getProvider(Long orgId); getPrimaryForOrg(Long) kept for legacy call sites (CallController, CapabilitiesController, SipController, webhook inbound). - RingCentral OAuth tokens now scoped by (orgId, provider, instanceId) so one org can authenticate multiple independent RingCentral deployments. - FreePBX construction reads config_json → {baseUrl, clientId, clientSecret, ignoreSslErrors} and instantiates a dedicated FreePBXGraphQLClient. RingCentral (RingCentralProvider): - Constructor takes instanceId for log context. - New methods: listExtensions / createExtension / updateExtension / deleteExtension; listUsers / createUser / updateUser / deleteUser (RC models both as type=User extensions); listDevices / createDevice / updateDevice / deleteDevice; fetchVoicemailAudio (streams attachment content) and fetchVoicemailTranscription. FreePBX (FreePBXProvider) — full implementation replaces placeholder: - Client-credentials OAuth2 token caching via FreePBXTokenCache (~1h TTL, auto-refresh on 401, per-instance). - FreePBXGraphQLClient: GraphQL + REST transports with optional skip-SSL-verification for self-signed on-prem PBXes. - Extensions, User Manager users, Endpoint Manager devices, voicemail list/mark-read/delete + audio stream, CDR call history, SIP credentials derived from the extension's pjsip secret, health via fetchAsteriskInfo. - SMS explicitly unsupported (capability sms=false) — FreePBX doesn't handle carrier SMS. Flowroute SMS (FlowrouteTextProvider): - Messages v2.1 API with HTTP Basic (accessKey, secretKey). - Health probe hits GET /numbers?limit=1. - Registered with BulkTextProviderFactory via new FLOWROUTE enum value. Controllers: - VoipInstanceController (renamed from ProviderConfigController) — full CRUD at /api/voip/instances with per-instance test/sync. Secrets redacted in GET responses ('***'); merge-update lets UI round-trip redacted fields without clobbering stored credentials. - BulkTextInstanceController (renamed from BulkTextConfigController) — mirror CRUD at /api/bulktext/instances with test / test-send / send. - OAuthController rewritten for instance-scoped OAuth: start, callback, status, disconnect all take instanceId. - SmsController resolves instance from member.instanceId → org primary, attaches to upserted conversations. - CallController / CapabilitiesController / SipController fall back to the org's primary active instance for legacy single-instance endpoints. Services: - InstanceSyncService: pull-through cache sync — extensions/users/devices/ voicemails copied from provider to local tables, missing rows soft-marked UNKNOWN. Each sub-step wrapped so one unsupported capability doesn't fail the entire sync (e.g. FreePBX no-SMS + has-extensions). - VoipMessageService: all conversation/message paths propagate instanceId. Tests: pre-existing VoipProviderConfig-specific tests removed (covered the renamed types; rewriting is out of scope per design spec §10 — no TDD infrastructure is being added in this refactor). Builds green with updated kamo-shared-library.