feat: 업로드 서비스에 p2v_video 대상 분기 추가

This commit is contained in:
skkim committed 2026-10-16 10:24:42 +09:00
1 parent ccf80b2cbf
commit 951a1721b5
1 file changed
+27 -2
+27 -2
View File
@@ -30,6 +30,7 @@ from app.social.services.sns_metadata import apply_sns_metadata, sns_metadata_ch
from app.social.worker.upload_task import process_social_upload
from app.user.models import User
from app.home.models import Project
from app.p2v.models import PosterAliveTask
from app.ssulbox.models import SsulContent
from app.video.models import Video
@@ -69,7 +70,30 @@ class SocialUploadService:
# ⚠️ 소유자 필터가 필수다. 대상 id 는 클라이언트가 보내는 값이라, 안 거르면
# **남의 콘텐츠를 자기 SNS 채널에 업로드**할 수 있다(계정 소유권만 검증하고
# 콘텐츠 소유권을 안 보면 IDOR 이 된다).
if body.content_type == "ssul":
if body.content_type == "p2v_video":
target_col = SocialUpload.p2v_video_id
# ⚠️ 소유자·삭제 필터 필수 — 안 거르면 남의 영상이 내 채널에 올라간다(IDOR).
# PosterAliveTask.user_id 는 user_uuid 컬럼의 속성 이름이다.
p2v_row = (
await session.execute(
select(PosterAliveTask).where(
PosterAliveTask.id == body.video_id,
PosterAliveTask.user_id == current_user.user_uuid,
PosterAliveTask.is_deleted.is_(False),
)
)
).scalar_one_or_none()
if not p2v_row:
logger.warning(f"[UPLOAD_SERVICE] P2V 영상 없음 - id: {body.video_id}")
raise VideoNotFoundError(video_id=body.video_id)
if p2v_row.status != "done" or not p2v_row.video_url:
logger.warning(f"[UPLOAD_SERVICE] P2V 영상 미완성 - id: {body.video_id}")
raise VideoNotFoundError(
video_id=body.video_id,
detail="영상이 아직 준비되지 않았습니다. 영상 생성이 완료된 후 시도해주세요.",
)
target = p2v_row
elif body.content_type == "ssul":
target_col = SocialUpload.content_id
content = (
await session.execute(
@@ -203,9 +227,10 @@ class SocialUploadService:
# 5. 새 업로드 레코드 생성
social_upload = SocialUpload(
user_uuid=current_user.user_uuid,
# 종류에 따라 둘 중 하나만 채운다 (CHECK ck_social_upload_one_target 이 강제)
# 종류에 따라 셋 중 하나만 채운다 (CHECK ck_social_upload_one_target 이 강제)
video_id=body.video_id if body.content_type == "video" else None,
content_id=body.video_id if body.content_type == "ssul" else None,
p2v_video_id=body.video_id if body.content_type == "p2v_video" else None,
social_account_id=account.id,
upload_seq=next_seq,
platform=account.platform,