MCPcopy
hub / github.com/apache/answer / RemoveComment

Method RemoveComment

internal/service/comment/comment_service.go:279–300  ·  view source on GitHub ↗

RemoveComment delete comment

(ctx context.Context, req *schema.RemoveCommentReq)

Source from the content-addressed store, hash-verified

277
278// RemoveComment delete comment
279func (cs *CommentService) RemoveComment(ctx context.Context, req *schema.RemoveCommentReq) (err error) {
280 commentInfo, exist, err := cs.commentCommonRepo.GetComment(ctx, req.CommentID)
281 if err != nil {
282 return err
283 }
284 if !exist {
285 return nil
286 }
287 err = cs.commentRepo.RemoveComment(ctx, req.CommentID)
288 if err != nil {
289 return err
290 }
291 cs.eventQueueService.Send(ctx, schema.NewEvent(constant.EventCommentDelete, req.UserID).
292 TID(req.CommentID).CID(req.CommentID, req.UserID))
293 if commentInfo.ObjectID == commentInfo.QuestionID {
294 cs.vectorSyncService.Send(ctx, &vector_sync.Task{Action: vector_sync.ActionUpsert, ObjectType: vector_sync.ObjectTypeQuestion, ObjectID: commentInfo.QuestionID})
295 } else {
296 cs.vectorSyncService.Send(ctx, &vector_sync.Task{Action: vector_sync.ActionUpsert, ObjectType: vector_sync.ObjectTypeAnswer, ObjectID: commentInfo.ObjectID})
297 cs.vectorSyncService.Send(ctx, &vector_sync.Task{Action: vector_sync.ActionUpsert, ObjectType: vector_sync.ObjectTypeQuestion, ObjectID: commentInfo.QuestionID})
298 }
299 return nil
300}
301
302// UpdateComment update comment
303func (cs *CommentService) UpdateComment(ctx context.Context, req *schema.UpdateCommentReq) (

Callers

nothing calls this directly

Calls 6

NewEventFunction · 0.92
CIDMethod · 0.80
TIDMethod · 0.80
GetCommentMethod · 0.65
RemoveCommentMethod · 0.65
SendMethod · 0.65

Tested by

no test coverage detected