40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""
|
|
내부 전용 소셜 업로드 API
|
|
|
|
스케줄러 서버에서만 호출하는 내부 엔드포인트입니다.
|
|
X-Internal-Secret 헤더로 인증합니다.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from fastapi import APIRouter, BackgroundTasks, Header, HTTPException, status
|
|
|
|
from app.social.worker.upload_task import process_social_upload
|
|
from config import internal_settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter(prefix="/internal/social", tags=["Internal"])
|
|
|
|
|
|
@router.post(
|
|
"/upload/{upload_id}",
|
|
summary="[내부] 예약 업로드 실행",
|
|
description="스케줄러 서버에서 호출하는 내부 전용 엔드포인트입니다.",
|
|
)
|
|
async def trigger_scheduled_upload(
|
|
upload_id: int,
|
|
background_tasks: BackgroundTasks,
|
|
x_internal_secret: str = Header(...),
|
|
) -> dict:
|
|
if x_internal_secret != internal_settings.INTERNAL_SECRET_KEY:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_403_FORBIDDEN,
|
|
detail="Invalid internal secret",
|
|
)
|
|
|
|
logger.info(f"[INTERNAL] 예약 업로드 실행 - upload_id: {upload_id}")
|
|
background_tasks.add_task(process_social_upload, upload_id)
|
|
|
|
return {"success": True, "upload_id": upload_id, "message": "업로드 작업이 시작되었습니다."}
|