mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
- Add integrations CRM and AI routing APIs; Salesforce OAuth refresh; lead CRM metadata - Marketer hub, settings CRM UI, OS views; premium landing and strategy_summary differentiators - Docs: API-MAP, product guide, competitive matrix, launch simulation, AGENT-MAP LLM routing - Sync script: strategy legal + competitive matrix to public; pytest DB isolation (.pytest_dealix.sqlite) - Tests: CRM status and AI routing smoke; check_go_live_gate UTF-8 stdout on Windows - Alembic migrations for strategic deal links and lead company/sector/city Made-with: Cursor
74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
"""Probe external integrations and persist status on IntegrationSyncState."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.services.crm_sync_service import CRMSyncService
|
|
from app.services.operations_hub import upsert_connector_status
|
|
|
|
logger = logging.getLogger("dealix.integration_probe")
|
|
|
|
|
|
async def probe_and_persist_crm_connectors(db: AsyncSession, tenant_id: UUID) -> None:
|
|
"""Update crm_salesforce / crm_hubspot connector rows from live probes (best-effort)."""
|
|
svc = CRMSyncService(db)
|
|
tid = str(tenant_id)
|
|
|
|
# Salesforce
|
|
try:
|
|
creds = await svc._get_crm_credentials(tid, "salesforce")
|
|
if not creds:
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_salesforce", status="unknown",
|
|
)
|
|
else:
|
|
probe = await svc.salesforce_identity_probe(creds)
|
|
if probe.get("ok"):
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_salesforce", status="ok", success=True,
|
|
)
|
|
else:
|
|
await upsert_connector_status(
|
|
db,
|
|
tenant_id,
|
|
"crm_salesforce",
|
|
status="error",
|
|
last_error=str(probe.get("detail") or probe)[:500],
|
|
)
|
|
except Exception as e:
|
|
logger.exception("Salesforce probe failed")
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_salesforce", status="error", last_error=str(e)[:500],
|
|
)
|
|
|
|
# HubSpot
|
|
try:
|
|
creds = await svc._get_crm_credentials(tid, "hubspot")
|
|
if not creds:
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_hubspot", status="unknown",
|
|
)
|
|
else:
|
|
probe = await svc.hubspot_identity_probe(creds.get("api_key", ""))
|
|
if probe.get("ok"):
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_hubspot", status="ok", success=True,
|
|
)
|
|
else:
|
|
await upsert_connector_status(
|
|
db,
|
|
tenant_id,
|
|
"crm_hubspot",
|
|
status="error",
|
|
last_error=str(probe.get("detail") or probe)[:500],
|
|
)
|
|
except Exception as e:
|
|
logger.exception("HubSpot probe failed")
|
|
await upsert_connector_status(
|
|
db, tenant_id, "crm_hubspot", status="error", last_error=str(e)[:500],
|
|
)
|