Skip to content

Commit

Permalink
fix(favorite): check video_id #221
Browse files Browse the repository at this point in the history
  • Loading branch information
Maple-pro committed Sep 1, 2023
1 parent 7524a4f commit ebed599
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/services/favorite/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,34 @@ func (c FavoriteServiceServerImpl) FavoriteAction(ctx context.Context, req *favo
"action_type": req.ActionType, //点赞 1 2 取消点赞
}).Debugf("Process start")

// Check if video exists
videoExistResp, err := feedClient.QueryVideoExisted(ctx, &feed.VideoExistRequest{
VideoId: req.VideoId,
})
if err != nil {
logger.WithFields(logrus.Fields{
"err": err,
}).Errorf("Query video existence happens error")
logging.SetSpanError(span, err)
resp = &favorite.FavoriteResponse{
StatusCode: strings.FeedServiceInnerErrorCode,
StatusMsg: strings.FeedServiceInnerError,
}
return
}

if !videoExistResp.Existed {
logger.WithFields(logrus.Fields{
"VideoId": req.VideoId,
}).Errorf("Video ID does not exist")
logging.SetSpanError(span, err)
resp = &favorite.FavoriteResponse{
StatusCode: strings.UnableToQueryVideoErrorCode,
StatusMsg: strings.UnableToQueryVideoError,
}
return
}

VideosRes, err := feedClient.QueryVideos(ctx, &feed.QueryVideosRequest{
ActorId: req.ActorId,
VideoIds: []uint32{req.VideoId},
Expand Down

0 comments on commit ebed599

Please sign in to comment.