feat(agent-office): drop daily realestate cron + bookmark callback routing
- scheduler.py: remove _run_realestate_schedule() and its 09:15 cron job
- service_proxy.py: add realestate_bookmark_toggle() helper (PATCH bookmark endpoint)
- webhook.py: add _handle_realestate_bookmark() dispatcher before DB-lookup path;
realestate_bookmark_{id} callbacks are handled inline without a DB entry
- tests/test_realestate_callback.py: 4 new unit tests covering happy path,
invalid id, proxy error, and regression that approve/reject still uses DB path
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,8 +30,13 @@ async def handle_webhook(data: dict, agent_dispatcher=None) -> Optional[dict]:
|
||||
|
||||
|
||||
async def _handle_callback(callback_query: dict) -> Optional[dict]:
|
||||
"""기존 승인/거절 콜백 처리 로직."""
|
||||
"""승인/거절 및 realestate 북마크 콜백 처리."""
|
||||
callback_id = callback_query.get("data", "")
|
||||
|
||||
# realestate 북마크 토글 콜백 — DB 조회 없이 직접 처리
|
||||
if callback_id.startswith("realestate_bookmark_"):
|
||||
return await _handle_realestate_bookmark(callback_query, callback_id)
|
||||
|
||||
cb = get_telegram_callback(callback_id)
|
||||
if not cb:
|
||||
return None
|
||||
@@ -60,6 +65,38 @@ async def _handle_callback(callback_query: dict) -> Optional[dict]:
|
||||
}
|
||||
|
||||
|
||||
async def _handle_realestate_bookmark(callback_query: dict, callback_id: str) -> dict:
|
||||
"""realestate_bookmark_{announcement_id} 콜백 처리."""
|
||||
from .. import service_proxy
|
||||
from .messaging import send_raw
|
||||
|
||||
# answerCallbackQuery 먼저 — 텔레그램 로딩 스피너 해제
|
||||
await api_call(
|
||||
"answerCallbackQuery",
|
||||
{"callback_query_id": callback_query["id"], "text": "처리 중..."},
|
||||
)
|
||||
|
||||
try:
|
||||
ann_id = int(callback_id.removeprefix("realestate_bookmark_"))
|
||||
except ValueError:
|
||||
await send_raw("⚠️ 잘못된 북마크 콜백 데이터")
|
||||
return {"ok": False, "error": "invalid_callback_data"}
|
||||
|
||||
try:
|
||||
result = await service_proxy.realestate_bookmark_toggle(ann_id)
|
||||
bookmarked = result.get("bookmarked", None)
|
||||
if bookmarked is True:
|
||||
await send_raw(f"🔖 북마크 추가 완료 (#{ann_id})")
|
||||
elif bookmarked is False:
|
||||
await send_raw(f"🔖 북마크 해제 완료 (#{ann_id})")
|
||||
else:
|
||||
await send_raw(f"🔖 북마크 토글 완료 (#{ann_id})")
|
||||
return {"ok": True, "announcement_id": ann_id}
|
||||
except Exception as e:
|
||||
await send_raw(f"⚠️ 북마크 처리 실패: {e}")
|
||||
return {"ok": False, "error": str(e)}
|
||||
|
||||
|
||||
async def _handle_message(message: dict, agent_dispatcher) -> Optional[dict]:
|
||||
"""슬래시 명령 메시지 처리."""
|
||||
from .router import parse_command, resolve_agent_command, HELP_TEXT
|
||||
|
||||
Reference in New Issue
Block a user