feat: 댓글 신고·차단·약관 동의(관리 스크립트 포함), 구글 로그인(서버·웹·안드로이드 앱), 앱 패키지 kr.o2o.nalssigak·versionCode 1000

This commit is contained in:
minaChoi committed 2026-10-26 09:45:00 +09:00
1 parent fbebdcb796
commit 3f3a3ea039
35 files changed
+1723 -115

No files matched your search

+36 -2
View File
@@ -1,3 +1,4 @@
import uuid
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
@@ -6,7 +7,7 @@ from fastapi import Depends
from common.database.db_session_manager import DB_SESSION_MNG
from common.database.model.models import Comment, Post, User
from common.enums import ErrorType
from common.enums import ErrorType, ReportReason
from crud.feed_crud import FeedCRUD
from crud.reaction_crud import ReactionCRUD
@@ -72,7 +73,7 @@ class ReactionService:
return err, [SavedView(post=p, saved_at=ps.created_at) for p, ps in rows or []]
async def comments(self, post_id: int, user: Optional[User], cursor: Optional[int]) -> tuple[ErrorType, list[CommentView]]:
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.comments(s, post_id, cursor, PAGE))
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.comments(s, post_id, user.user_id if user else None, cursor, PAGE))
if err is not ErrorType.SUCCESS:
return err, []
liked: set[int] = set()
@@ -87,6 +88,8 @@ class ReactionService:
body = body.strip()
if not body or len(body) > COMMENT_MAX:
return ErrorType.INVALID_INPUT, None
if user.terms_agreed_at is None:
return ErrorType.TERMS_REQUIRED, None
err = await self._post_exists(post_id)
if err is not ErrorType.SUCCESS:
return err, None
@@ -104,3 +107,34 @@ class ReactionService:
if err is not ErrorType.SUCCESS:
return err, None
return (ErrorType.NOT_FOUND, None) if count is None else (ErrorType.SUCCESS, count)
async def _others_comment(self, comment_id: int, user: User) -> tuple[ErrorType, Optional[uuid.UUID]]:
"""남이 쓴, 지금 보이는 댓글의 작성자. 내 댓글이면 INVALID_INPUT."""
err, author = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.comment_author(s, comment_id))
if err is not ErrorType.SUCCESS:
return err, None
if author is None:
return ErrorType.NOT_FOUND, None
return (ErrorType.INVALID_INPUT, None) if author == user.user_id else (ErrorType.SUCCESS, author)
async def report_comment(self, comment_id: int, user: User, reason: ReportReason) -> ErrorType:
err, _ = await self._others_comment(comment_id, user)
if err is not ErrorType.SUCCESS:
return err
return await DB_SESSION_MNG.execute_lambda_run([lambda s: self.crud.report_comment(s, comment_id, user.user_id, reason.value)])
async def block_author(self, comment_id: int, user: User) -> ErrorType:
err, author = await self._others_comment(comment_id, user)
if err is not ErrorType.SUCCESS:
return err
return await DB_SESSION_MNG.execute_lambda_run([lambda s: self.crud.block(s, user.user_id, author)])
async def unblock(self, user: User, blocked_id: uuid.UUID) -> ErrorType:
err, ok = await DB_SESSION_MNG.execute_lambda_write(lambda s: self.crud.unblock(s, user.user_id, blocked_id))
if err is not ErrorType.SUCCESS:
return err
return ErrorType.SUCCESS if ok else ErrorType.NOT_FOUND
async def blocked(self, user: User) -> tuple[ErrorType, list[User]]:
err, users = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.blocked(s, user.user_id))
return err, users or []