@@ -19,9 +19,11 @@ class CommentCreate(BaseModel):
1919 season_number : Optional [int ] = None
2020 episode_number : Optional [int ] = None
2121 content : str
22+ is_spoiler : bool = False
2223
2324class CommentUpdate (BaseModel ):
2425 content : str
26+ is_spoiler : bool = False
2527
2628class CommentResponse (BaseModel ):
2729 id : int
@@ -85,6 +87,7 @@ async def list_comments(
8587 "avatar_url" : f"/profile/avatar/{ c .user_id } " if (c .user .profile and c .user .profile .avatar_path ) else None ,
8688 "user_is_public" : c .user .profile .privacy_level == PrivacyLevel .public if c .user .profile else False ,
8789 "content" : c .content ,
90+ "is_spoiler" : c .is_spoiler ,
8891 "created_at" : c .created_at .isoformat (),
8992 "updated_at" : c .updated_at .isoformat () if c .updated_at else None ,
9093 }
@@ -107,11 +110,12 @@ async def create_comment(
107110 season_number = body .season_number ,
108111 episode_number = body .episode_number ,
109112 content = body .content ,
113+ is_spoiler = body .is_spoiler ,
110114 )
111115 db .add (comment )
112116 await db .commit ()
113117 await db .refresh (comment )
114-
118+
115119 return {
116120 "id" : comment .id ,
117121 "user_id" : comment .user_id ,
@@ -120,6 +124,7 @@ async def create_comment(
120124 "avatar_url" : f"/profile/avatar/{ current_user .id } " if (current_user .profile and current_user .profile .avatar_path ) else None ,
121125 "user_is_public" : current_user .profile .privacy_level == PrivacyLevel .public if current_user .profile else False ,
122126 "content" : comment .content ,
127+ "is_spoiler" : comment .is_spoiler ,
123128 "created_at" : comment .created_at .isoformat (),
124129 }
125130
@@ -144,12 +149,14 @@ async def update_comment(
144149 raise HTTPException (status_code = 400 , detail = "Comment content cannot be empty" )
145150
146151 comment .content = stripped
152+ comment .is_spoiler = body .is_spoiler
147153 await db .commit ()
148154 await db .refresh (comment )
149155
150156 return {
151157 "id" : comment .id ,
152158 "content" : comment .content ,
159+ "is_spoiler" : comment .is_spoiler ,
153160 "updated_at" : comment .updated_at .isoformat () if comment .updated_at else None ,
154161 }
155162
0 commit comments