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
@@ -24,6 +24,12 @@ def _comment(v: CommentView) -> CommentData:
|
||||
return CommentData(comment_id=c.comment_id, nickname=v.nickname, character=v.character, color=v.color, mood=v.mood, body=c.body, like_count=c.like_count, liked=v.liked, mine=v.mine, official=v.official, created_at=c.created_at.astimezone(KST))
|
||||
|
||||
|
||||
def _comment_list(err: ErrorType, items: list[CommentView]) -> Res_CommentList:
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_CommentList(result=error_info(err))
|
||||
return Res_CommentList(comments=[_comment(v) for v in items], next_cursor=items[-1].comment.comment_id if len(items) == PAGE else None)
|
||||
|
||||
|
||||
async def _like(post_id: int, who: Liker, on: bool, service: ReactionService) -> Res_PostLike:
|
||||
err, count = await service.like_post(post_id, who, on)
|
||||
return Res_PostLike(result=error_info(err)) if err is not ErrorType.SUCCESS else Res_PostLike(liked=on, like_count=count)
|
||||
@@ -65,10 +71,7 @@ async def list_comments(
|
||||
post_id: int = Path(...), cursor: Optional[int] = Query(None), user: Optional[User] = Depends(optional_user), who: Liker = Depends(liker),
|
||||
service: ReactionService = Depends(),
|
||||
) -> Res_CommentList:
|
||||
err, items = await service.comments(post_id, user, who.ip_hash, cursor)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_CommentList(result=error_info(err))
|
||||
return Res_CommentList(comments=[_comment(v) for v in items], next_cursor=items[-1].comment.comment_id if len(items) == PAGE else None)
|
||||
return _comment_list(*await service.comments(post_id, user, who.ip_hash, cursor))
|
||||
|
||||
|
||||
@router.post("/post/{post_id}/comment", response_model=Res_Comment, response_model_exclude_none=True, summary="댓글 쓰기 (60자, 로그인 없으면 '동네 익명'으로 IP 당 하루 20개, 로그인했는데 이용약관 동의 전이면 TERMS_REQUIRED)")
|
||||
@@ -79,6 +82,22 @@ async def add_comment(
|
||||
return Res_Comment(result=error_info(err)) if err is not ErrorType.SUCCESS else Res_Comment(comment=_comment(v))
|
||||
|
||||
|
||||
@router.get("/talk/{talk_id}/comment/list", response_model=Res_CommentList, response_model_exclude_none=True, summary="사람 글 댓글 목록 (로그인 없이 보기)")
|
||||
async def list_talk_comments(
|
||||
talk_id: int = Path(...), cursor: Optional[int] = Query(None), user: Optional[User] = Depends(optional_user), who: Liker = Depends(liker),
|
||||
service: ReactionService = Depends(),
|
||||
) -> Res_CommentList:
|
||||
return _comment_list(*await service.comments(None, user, who.ip_hash, cursor, talk_id))
|
||||
|
||||
|
||||
@router.post("/talk/{talk_id}/comment", response_model=Res_Comment, response_model_exclude_none=True, summary="사람 글 댓글 쓰기 (로그인한 사람만, 60자, 링크·전화번호 불가, 이용약관 동의 전이면 TERMS_REQUIRED). 지우기·좋아요·신고·차단은 /comment/{comment_id} 그대로")
|
||||
async def add_talk_comment(
|
||||
talk_id: int = Path(...), req: Req_Comment = ..., user: User = Depends(current_user), who: Liker = Depends(liker), service: ReactionService = Depends(),
|
||||
) -> Res_Comment:
|
||||
err, v = await service.add_talk_comment(talk_id, user, who, req.body)
|
||||
return Res_Comment(result=error_info(err)) if err is not ErrorType.SUCCESS else Res_Comment(comment=_comment(v))
|
||||
|
||||
|
||||
@router.delete("/comment/{comment_id}", response_model=Res_WebPacketProtocol, response_model_exclude_none=True, summary="내 댓글 지우기 (로그인 없이 쓴 댓글은 같은 IP 에서)")
|
||||
async def delete_comment(comment_id: int = Path(...), who: Liker = Depends(liker), service: ReactionService = Depends()) -> Res_WebPacketProtocol:
|
||||
return Res_WebPacketProtocol(result=error_info(await service.delete_comment(comment_id, who)))
|
||||
|
||||
@@ -19,6 +19,7 @@ class TalkData(WebPacketProtocol):
|
||||
image: Optional[str] = Field(None, description="올린 사진 주소")
|
||||
topic: TalkTopic = TalkTopic.LOCAL
|
||||
like_count: int
|
||||
comment_count: int = 0
|
||||
liked: bool
|
||||
mine: bool
|
||||
created_at: datetime
|
||||
|
||||
@@ -23,7 +23,7 @@ def _data(v: TalkView) -> TalkData:
|
||||
t, u = v.talk, v.author
|
||||
return TalkData(
|
||||
talk_id=t.talk_id, nickname=u.nickname, character=u.character, color=u.color, mood=u.mood, region_name=v.region_name, weather=t.weather,
|
||||
body=t.body, image=t.image, topic=TalkTopic(t.topic), like_count=t.like_count, liked=v.liked, mine=v.mine, created_at=t.created_at.astimezone(KST),
|
||||
body=t.body, image=t.image, topic=TalkTopic(t.topic), like_count=t.like_count, comment_count=t.comment_count, liked=v.liked, mine=v.mine, created_at=t.created_at.astimezone(KST),
|
||||
ago=ago_text(t.created_at, now_kst()),
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user