From bea06e3069f5828d6fe3580b1fd50e3ca01f4db8 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Tue, 14 Oct 2025 00:41:35 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Slack=20Lists=20=EC=B2=A8=EB=B6=80?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EA=B3=84=ED=9A=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - skill-rag-file: GET /api/download/{document_id} 추가 필요 - skill-slack: POST /api/v1/files/upload 추가 필요 - coldmail_briefing.py:159-204: 파일 다운로드 → 업로드 → file_id 통합 필요 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../251014_slack_lists_file_attachment.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 troubleshooting/251014_slack_lists_file_attachment.md diff --git a/troubleshooting/251014_slack_lists_file_attachment.md b/troubleshooting/251014_slack_lists_file_attachment.md new file mode 100644 index 0000000..887ad20 --- /dev/null +++ b/troubleshooting/251014_slack_lists_file_attachment.md @@ -0,0 +1,84 @@ +# Slack Lists 첨부파일 업로드 구현 + +**날짜**: 2025-10-14 +**작성자**: happybell80 +**관련 파일**: `rb8001/app/scheduler/jobs/coldmail_briefing.py` + +--- + +## 문제 상황 + +- coldmail_briefing.py:204: attachment 필드에 document_id 문자열 전달 +- Slack Lists API는 file_id 필요 (skill-slack/tests/test_slack_lists.py:112) + +--- + +## 현재 상태 + +### skill-rag-file +- main.py:54: POST /api/upload 존재 +- upload.py:108: storage_path에 파일 저장 +- 다운로드 API 없음 + +### skill-slack +- lists.py:47: POST /lists/items 존재 (slackLists.items.create) +- messages.py:19: POST /send 존재 (chat_postMessage) +- files_upload_v2 통합 없음 + +### test_slack_lists.py (검증된 동작) +- 81-88줄: files_upload_v2(channel, file, title) → file_id 반환 +- 112줄: attachment 필드에 [file_id] 전달 +- 192줄: channel 파라미터 있으면 메시지 생성, 없으면 업로드만 + +--- + +## 해결 방안 + +### 우선순위 1: skill-rag-file 다운로드 API + +**파일**: skill-rag-file/app/api/download.py (신규) +- GET /api/download/{document_id} +- TeamDocument.query(id=document_id) → storage_path, filename 조회 +- from fastapi.responses import FileResponse +- return FileResponse(path=storage_path, filename=filename) + +**파일**: skill-rag-file/app/main.py:55 +- from app.api import download +- app.include_router(download.router, prefix="/api", tags=["download"]) + +**DB**: app/models/database.py:7-28 +- TeamDocument.storage_path (Text) +- TeamDocument.filename (String(255)) + +### 우선순위 2: skill-slack 파일 업로드 API + +**파일**: skill-slack/app/api/endpoints/files.py (신규) +- POST /api/v1/files/upload (multipart/form-data) +- from slack_sdk import WebClient +- client = WebClient(token=token) +- result = client.files_upload_v2(file=file, title=title) +- return {"file_id": result['file']['id']} + +**참고**: messages.py:17 (WebClient 초기화), test_slack_lists.py:81-88 + +### 우선순위 3: coldmail_briefing.py 통합 + +**위치**: rb8001/app/scheduler/jobs/coldmail_briefing.py:159-204 +- GET {SKILL_RAG_FILE_URL}/api/download/{document_id} +- 파일 /tmp/{filename} 저장 +- POST {SKILL_SLACK_URL}/api/v1/files/upload (multipart) +- 204줄: attachment: [file_id] + +--- + +## 교훈 + +### 테스트 파일 확인 누락 +- test_slack_lists.py에 완전한 구현 예시 존재 +- 문서만 보고 추측으로 작성 +- 교훈: 테스트 파일 우선 확인 필수 + +### API 스펙 미확인 +- attachment 필드 타입 확인 안 함 +- document_id 문자열 전달 (오류) +- 교훈: Slack API 필드 타입 사전 확인 필수