fix: 회고 채널 봇 메시지 필터링으로 무한 루프 방지

확인 메시지가 다시 폴링되어 재전송되는 루프 발생.
RETROSPECT_USER_IDS로 허용된 사용자만 포워딩.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-19 15:19:56 +09:00
parent 99c35fa829
commit 2c439803d7

View File

@@ -29,6 +29,8 @@ RETROSPECT_CHANNEL_ID = int(os.getenv("RETROSPECT_CHANNEL_ID", "0"))
RETROSPECT_CHAT_WEBHOOK_URL = os.getenv("RETROSPECT_CHAT_WEBHOOK_URL", "")
N8N_RETROSPECT_WEBHOOK_URL = os.getenv("N8N_RETROSPECT_WEBHOOK_URL",
"http://localhost:5678/webhook/retrospect")
# 회고 채널에서 포워딩할 사용자 ID (봇 메시지 제외)
RETROSPECT_USER_IDS = {int(x) for x in os.getenv("RETROSPECT_USER_IDS", "6").split(",") if x.strip()}
# State
sid: str = ""
@@ -175,8 +177,10 @@ async def poll_retrospect_channel(client: httpx.AsyncClient):
post_id = post.get("post_id", 0)
if post_id <= retro_last_seen_post_id:
continue
# 텍스트 메시지만 포워딩 (파일/시스템 메시지 제외)
if post.get("type", "normal") == "normal" and post.get("message", "").strip():
# 텍스트 메시지만 포워딩 (파일/시스템/봇 메시지 제외)
if (post.get("type", "normal") == "normal"
and post.get("message", "").strip()
and post.get("creator_id", 0) in RETROSPECT_USER_IDS):
await forward_to_n8n(post)
if posts:
max_id = max(p.get("post_id", 0) for p in posts)