feat(sync): 接 WA 自动同步(accounts+friends wiring to orchestrator/scheduler)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,8 @@ from app.sync.orchestrator import (
|
||||
sync_wechat_groups,
|
||||
sync_wechat_messages,
|
||||
sync_wechat_voice_calls,
|
||||
sync_whatsapp_accounts,
|
||||
sync_whatsapp_friends,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -160,6 +162,18 @@ async def _run_wa_voice_calls(
|
||||
return [await sync_wa_voice_calls(session, client)]
|
||||
|
||||
|
||||
async def _run_wa_accounts(
|
||||
session: AsyncSession, client: YunkeClient, store: ObjectStore
|
||||
) -> list[SyncResult]:
|
||||
return [await sync_whatsapp_accounts(session, client)]
|
||||
|
||||
|
||||
async def _run_wa_friends(
|
||||
session: AsyncSession, client: YunkeClient, store: ObjectStore
|
||||
) -> list[SyncResult]:
|
||||
return [await sync_whatsapp_friends(session, client)]
|
||||
|
||||
|
||||
async def _run_phone_calls(
|
||||
session: AsyncSession, client: YunkeClient, store: ObjectStore
|
||||
) -> list[SyncResult]:
|
||||
@@ -216,6 +230,12 @@ async def _run_all(
|
||||
This is the entity the scheduler's daily job runs.
|
||||
"""
|
||||
results = await _run_all_wechat(session, client, store)
|
||||
# WhatsApp entities (accounts + friends). WA voice calls are already
|
||||
# included via ``_run_all_wechat``; accounts + friends need their own
|
||||
# kick here. WA friends depend on the department tree (root dept id),
|
||||
# which ``_run_all_wechat`` seeds via sync_departments — so order matters.
|
||||
results.append(await sync_whatsapp_accounts(session, client))
|
||||
results.append(await sync_whatsapp_friends(session, client))
|
||||
results.append(await sync_phone_calls(session, client))
|
||||
results.append(await sync_sms(session, client))
|
||||
return results
|
||||
@@ -233,6 +253,8 @@ ENTITY_FUNCS: dict[
|
||||
"groups": _run_groups,
|
||||
"voice_calls": _run_voice_calls,
|
||||
"wa_voice_calls": _run_wa_voice_calls,
|
||||
"wa_accounts": _run_wa_accounts,
|
||||
"wa_friends": _run_wa_friends,
|
||||
"phone_calls": _run_phone_calls,
|
||||
"sms": _run_sms,
|
||||
"call_recordings": _run_call_recordings,
|
||||
|
||||
Reference in New Issue
Block a user