From 9cb52fbdb8be60e06e8a4e7e6f7f89ee57497e20 Mon Sep 17 00:00:00 2001 From: EpicMo <1982742309@qq.com> Date: Fri, 1 Sep 2023 16:35:24 +0800 Subject: [PATCH] feat: anonymity user --- src/web/feed/handler.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/web/feed/handler.go b/src/web/feed/handler.go index a752ac6..1660838 100644 --- a/src/web/feed/handler.go +++ b/src/web/feed/handler.go @@ -13,6 +13,7 @@ import ( _ "github.com/mbobakov/grpc-consul-resolver" "github.com/sirupsen/logrus" "net/http" + "strconv" ) var Client feed.FeedServiceClient @@ -42,7 +43,17 @@ func ListVideosByRecommendHandle(c *gin.Context) { actorId := uint32(req.ActorId) var res *feed.ListFeedResponse var err error - if actorId == 0 { + anonymity, err := strconv.ParseUint(config.EnvCfg.AnonymityUser, 10, 32) + if err != nil { + c.JSON(http.StatusOK, models.ListVideosRes{ + StatusCode: strings.FeedServiceInnerErrorCode, + StatusMsg: strings.FeedServiceInnerError, + NextTime: nil, + VideoList: nil, + }) + return + } + if actorId == uint32(anonymity) { res, err = Client.ListVideos(c.Request.Context(), &feed.ListFeedRequest{ LatestTime: &latestTime, ActorId: &actorId,