fix version 1
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
// DeleteComment 删除评论
|
||||
func DeleteComment(ctx context.Context, in *pb.DeleteCommentRequest) (*pb.StatusReply, error) {
|
||||
_, err := service.ParseMetaCtx(ctx, nil)
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -21,6 +21,14 @@ func DeleteComment(ctx context.Context, in *pb.DeleteCommentRequest) (*pb.Status
|
||||
if in.GetIdentity() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
// 校验归属:仅评论作者可删除
|
||||
comment, err := models.GetCommentForAuth(in.Identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if comment.OwnerIdentity != auth.Identity {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
err = models.DeleteComment(in.Identity)
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
|
||||
Reference in New Issue
Block a user