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

+21 -6
View File
@@ -6,7 +6,7 @@ from typing import Optional
from sqlalchemy import delete, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from common.database.model.models import Comment, CommentLike, Post, PostLike, PostSave, User
from common.database.model.models import Comment, CommentLike, CommentReport, Post, PostLike, PostSave, User, UserBlock
class UserCRUD:
@@ -23,6 +23,12 @@ class UserCRUD:
await s.flush()
return user
async def create_google(self, s: AsyncSession, sub: str, nickname: str) -> User:
user = User(login_id=f"google_{sub}", provider_uid=sub, nickname=nickname, provider=2)
s.add(user)
await s.flush()
return user
async def update(self, s: AsyncSession, user_id: uuid.UUID, values: dict) -> Optional[User]:
user = await self.get(s, user_id)
if user is None:
@@ -33,8 +39,11 @@ class UserCRUD:
await s.flush()
return user
async def agree_terms(self, s: AsyncSession, user_id: uuid.UUID) -> None:
await s.execute(update(User).where(User.user_id == user_id, User.terms_agreed_at.is_(None)).values(terms_agreed_at=datetime.now(timezone.utc)))
async def withdraw(self, s: AsyncSession, user_id: uuid.UUID) -> None:
"""계정과 그 사람이 남긴 좋아요·저장·댓글을 모두 지우고, 게시물·댓글에 쌓인 수를 그만큼 줄인다."""
"""계정과 그 사람이 남긴 좋아요·저장·댓글·신고·차단을 모두 지우고, 게시물·댓글에 쌓인 수를 그만큼 줄인다."""
liked_posts = (await s.scalars(delete(PostLike).where(PostLike.user_id == user_id).returning(PostLike.post_id))).all()
if liked_posts:
await s.execute(update(Post).where(Post.post_id.in_(liked_posts)).values(like_count=Post.like_count - 1))
@@ -42,10 +51,16 @@ class UserCRUD:
if liked_comments:
await s.execute(update(Comment).where(Comment.comment_id.in_(liked_comments)).values(like_count=Comment.like_count - 1))
await s.execute(delete(PostSave).where(PostSave.user_id == user_id))
mine = (await s.execute(delete(Comment).where(Comment.user_id == user_id).returning(Comment.comment_id, Comment.post_id, Comment.deleted))).all()
reported = (await s.scalars(delete(CommentReport).where(CommentReport.user_id == user_id).returning(CommentReport.comment_id))).all()
if reported:
await s.execute(update(Comment).where(Comment.comment_id.in_(reported)).values(report_count=Comment.report_count - 1))
await s.execute(delete(UserBlock).where((UserBlock.user_id == user_id) | (UserBlock.blocked_id == user_id)))
mine = (await s.execute(delete(Comment).where(Comment.user_id == user_id).returning(Comment.comment_id, Comment.post_id, Comment.deleted, Comment.is_hidden))).all()
if mine:
await s.execute(delete(CommentLike).where(CommentLike.comment_id.in_([c for c, _, _ in mine])))
# 이미 지운 댓글은 댓글 수에서 빠져 있다
for post_id, n in Counter(p for _, p, deleted in mine if not deleted).items():
ids = [c for c, _, _, _ in mine]
await s.execute(delete(CommentLike).where(CommentLike.comment_id.in_(ids)))
await s.execute(delete(CommentReport).where(CommentReport.comment_id.in_(ids)))
# 이미 지웠거나 숨긴 댓글은 댓글 수에서 빠져 있다
for post_id, n in Counter(p for _, p, deleted, hidden in mine if not deleted and not hidden).items():
await s.execute(update(Post).where(Post.post_id == post_id).values(comment_count=Post.comment_count - n))
await s.execute(delete(User).where(User.user_id == user_id))