File tree Expand file tree Collapse file tree 3 files changed +3
-7
lines changed
Expand file tree Collapse file tree 3 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { WebhookEvent } from "@clerk/nextjs/server";
88import { createUser , deleteUser , updateUser } from "@/lib/actions/user.action" ;
99
1010export async function POST ( req : Request ) {
11- // TODO: Add your own Clerk webhook secret here
1211 // You can find this in the Clerk Dashboard -> Webhooks -> choose the webhook
1312 const WEBHOOK_SECRET = process . env . CLERK_WEBHOOK_SECRET ;
1413
@@ -65,7 +64,7 @@ export async function POST(req: Request) {
6564 const mongoUser = await createUser ( {
6665 clerkId : id ,
6766 name : `${ first_name } ${ last_name ? ` ${ last_name } ` : "" } ` ,
68- username : username ! ,
67+ username : username || "" ,
6968 email : email_addresses [ 0 ] . email_address ,
7069 picture : image_url ,
7170 } ) ;
Original file line number Diff line number Diff line change @@ -98,9 +98,7 @@ export async function deleteAnswer(params: DeleteAnswerParams) {
9898 { $pull : { answers : answerId } }
9999 ) ;
100100
101- // todo: delete all interactions related to the answer
102-
103- // todo: decrement author's reputation by +S for deleting a answer
101+ await Interaction . deleteMany ( { answer : answerId } ) ;
104102
105103 revalidatePath ( path ) ;
106104 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -125,14 +125,13 @@ export async function deleteQuestion(params: DeleteQuestionParams) {
125125
126126 await Answer . deleteMany ( { question : questionId } ) ;
127127
128- // todo: delete all interactions related to the question
128+ await Interaction . deleteMany ( { question : questionId } ) ;
129129
130130 await Tag . updateMany (
131131 { questions : questionId } ,
132132 { $pull : { questions : questionId } }
133133 ) ;
134134
135- // todo: decrement author's reputation by +S for deleting a answer
136135 await User . findByIdAndUpdate ( question . author , {
137136 $inc : { reputation : - 10 } ,
138137 } ) ;
You can’t perform that action at this time.
0 commit comments