feat: NanoClaude Phase 3 — Synology Chat 연동
- POST /webhook/synology: outgoing webhook 수신 + token 검증 - 파이프라인 완료 시 incoming webhook으로 응답 자동 전송 - "분석 중..." typing 메시지 선전송 - 응답 길이 1500자 제한 (Synology Chat 제한 대응) - 에러/실패 시에도 사용자에게 알림 메시지 전송 - 중복 요청 방지 (30초 TTL dedup) - Synology에서 rewrite 이벤트 숨김 (SSE에서만 노출) - callback 구조로 확장 가능 (Slack, Discord 등) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
35
nanoclaude/services/synology_sender.py
Normal file
35
nanoclaude/services/synology_sender.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""Synology Chat — incoming webhook으로 응답 전송."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
import httpx
|
||||
|
||||
from config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def send_to_synology(text: str) -> bool:
|
||||
"""Incoming webhook URL로 메시지 전송. 성공 시 True."""
|
||||
if not settings.synology_incoming_url:
|
||||
logger.warning("Synology incoming URL not configured")
|
||||
return False
|
||||
|
||||
payload = json.dumps({"text": text}, ensure_ascii=False)
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient(verify=False, timeout=10.0) as client:
|
||||
resp = await client.post(
|
||||
settings.synology_incoming_url,
|
||||
data={"payload": payload},
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
return True
|
||||
logger.error("Synology send failed: %d %s", resp.status_code, resp.text)
|
||||
return False
|
||||
except Exception:
|
||||
logger.exception("Failed to send to Synology Chat")
|
||||
return False
|
||||
Reference in New Issue
Block a user