feat: 오늘 피드 — 사람 글을 묶음 대신 포스트처럼 두 장마다 한 장씩(큰 카드·댓글), 행사는 띠 대신 축제 전부와 팝업·전시·공연 2개씩 포스트로
- 사람 글 큰 카드: 머리줄·4:5 본문(사진, 없으면 글을 크게)·좋아요·댓글·보내기 - 사람 글 댓글: 로그인한 사람만, comment 표에 talk_id, talk.comment_count (init.sql) - '오늘 내 글'·'동네 사람들'·주제별 묶음, '이번 주 가까운 행사' 띠 제거 - 행사 포스트 자리 최대 40개, 앞쪽 절반에 다 못 들어가면 끝까지 한 장씩 걸러 - GA: feed_item_view(talk·event 노출), talk_comment
This commit is contained in:
1 parent
f6cb6f2deb
commit
dba3d78f14
22 files changed
+653
-318
No files matched your search
@@ -13,6 +13,7 @@ from common.utils.kma_time import kst_midnight, now_kst
|
||||
from crud.feed_crud import FeedCRUD
|
||||
from crud.reaction_crud import ReactionCRUD
|
||||
from crud.region_crud import RegionCRUD
|
||||
from crud.talk_crud import TalkCRUD
|
||||
from services.bot_comment import BOT_COLORS, BOT_NAMES
|
||||
from services.level_service import award
|
||||
from services.talk_service import _LINK, _PHONE
|
||||
@@ -43,8 +44,10 @@ class SavedView:
|
||||
|
||||
|
||||
class ReactionService:
|
||||
def __init__(self, crud: ReactionCRUD = Depends(ReactionCRUD), feed: FeedCRUD = Depends(FeedCRUD), regions: RegionCRUD = Depends(RegionCRUD)) -> None:
|
||||
self.crud, self.feed, self.regions = crud, feed, regions
|
||||
def __init__(
|
||||
self, crud: ReactionCRUD = Depends(ReactionCRUD), feed: FeedCRUD = Depends(FeedCRUD), regions: RegionCRUD = Depends(RegionCRUD), talks: TalkCRUD = Depends(TalkCRUD),
|
||||
) -> None:
|
||||
self.crud, self.feed, self.regions, self.talks = crud, feed, regions, talks
|
||||
|
||||
async def _post_exists(self, post_id: int) -> ErrorType:
|
||||
err, post = await DB_SESSION_MNG.execute_lambda(lambda s: self.feed.get(s, post_id))
|
||||
@@ -100,8 +103,9 @@ class ReactionService:
|
||||
return CommentView(comment=c, nickname=f"{c.region_name} 익명" if c.region_name else "익명", character=ANON_CHARACTER, color=ANON_COLOR, mood=None, liked=liked, mine=mine)
|
||||
return CommentView(comment=c, nickname=nickname or "", character=character or ANON_CHARACTER, color=color or ANON_COLOR, mood=mood, liked=liked, mine=c.user_id == who.user_id)
|
||||
|
||||
async def comments(self, post_id: int, user: Optional[User], ip_hash: str, cursor: Optional[int]) -> tuple[ErrorType, list[CommentView]]:
|
||||
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))
|
||||
async def comments(self, post_id: Optional[int], user: Optional[User], ip_hash: str, cursor: Optional[int], talk_id: Optional[int] = None) -> tuple[ErrorType, list[CommentView]]:
|
||||
"""포스트 댓글, talk_id 가 있으면 그 사람 글의 댓글."""
|
||||
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, talk_id))
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return err, []
|
||||
liked: set[int] = set()
|
||||
@@ -146,6 +150,26 @@ class ReactionService:
|
||||
await award(user.user_id, "react", f"comment:{c.comment_id}")
|
||||
return err, self._view(c, user.nickname, user.character, user.color, user.mood, False, who)
|
||||
|
||||
async def add_talk_comment(self, talk_id: int, user: User, who: Liker, body: str) -> tuple[ErrorType, Optional[CommentView]]:
|
||||
"""사람 글 댓글은 로그인한 사람만 쓴다. 글처럼 링크·전화번호는 막는다."""
|
||||
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
|
||||
if _LINK.search(body) or _PHONE.search(body):
|
||||
return ErrorType.LINK_NOT_ALLOWED, None
|
||||
err, talk = await DB_SESSION_MNG.execute_lambda(lambda s: self.talks.get(s, talk_id))
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return err, None
|
||||
if talk is None or talk.hidden:
|
||||
return ErrorType.NOT_FOUND, None
|
||||
err, c = await DB_SESSION_MNG.execute_lambda_write(lambda s: self.crud.add_comment(s, None, who, body, None, talk_id))
|
||||
if c is None:
|
||||
return err, None
|
||||
await award(user.user_id, "react", f"comment:{c.comment_id}")
|
||||
return err, self._view(c, user.nickname, user.character, user.color, user.mood, False, who)
|
||||
|
||||
async def delete_comment(self, comment_id: int, who: Liker) -> ErrorType:
|
||||
err, ok = await DB_SESSION_MNG.execute_lambda_write(lambda s: self.crud.delete_comment(s, comment_id, who))
|
||||
if err is not ErrorType.SUCCESS:
|
||||
|
||||
Reference in new issue
Block a user