From 951a1721b5ca023936a9f340e0ed8a9bc6e9be36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Fri, 16 Oct 2026 10:24:42 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=EC=97=90=20p2v=5Fvideo=20=EB=8C=80=EC=83=81?= =?UTF-8?q?=20=EB=B6=84=EA=B8=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/social/services/upload_service.py | 29 +++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/social/services/upload_service.py b/app/social/services/upload_service.py index e3fe1f9..85e6da8 100644 --- a/app/social/services/upload_service.py +++ b/app/social/services/upload_service.py @@ -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,