From 7e6e5aaf1c35e291b57ef3f4268b6e736e37458b Mon Sep 17 00:00:00 2001 From: cuishuang Date: Fri, 27 Sep 2024 20:43:33 +0800 Subject: [PATCH 1/2] fix: fix slice init length Signed-off-by: cuishuang --- internal/dao/jinzhu/topics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/dao/jinzhu/topics.go b/internal/dao/jinzhu/topics.go index 639f32d4..68b59f42 100644 --- a/internal/dao/jinzhu/topics.go +++ b/internal/dao/jinzhu/topics.go @@ -173,7 +173,7 @@ func (s *topicSrv) listTags(conditions *ms.ConditionsT, limit int, offset int) ( tagMap[item.UserID] = append(tagMap[item.UserID], item) res = append(res, item) } - ids := make([]int64, len(tagMap)) + ids := make([]int64, 0, len(tagMap)) for userId := range tagMap { ids = append(ids, userId) } @@ -332,7 +332,7 @@ func (s *topicSrvA) ListTags(typ cs.TagType, offset, limit int) (res cs.TagList, tagMap[item.UserID] = append(tagMap[item.UserID], item) res = append(res, item) } - ids := make([]int64, len(tagMap)) + ids := make([]int64, 0, len(tagMap)) for userId := range tagMap { ids = append(ids, userId) } From 6d8088d1f7587c3342c2a6060518dfc6887f9531 Mon Sep 17 00:00:00 2001 From: chengyuxuan <62170231+Q-xuan@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:21:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix/=E4=BF=AE=E6=94=B9=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=97=A0=E6=B3=95=E6=9F=A5=E7=9C=8B=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E5=8F=91=E8=A1=A8=E7=9A=84=E6=96=87=E7=AB=A0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改普通用户无法查看自己发表的文章问题 --- internal/servants/web/loose.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/servants/web/loose.go b/internal/servants/web/loose.go index 4ec8f62c..d98b8190 100644 --- a/internal/servants/web/loose.go +++ b/internal/servants/web/loose.go @@ -532,6 +532,9 @@ func (s *looseSrv) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, m // 检测访问权限 // TODO: 提到最前面去检测 switch { + case req.User.ID == postFormated.User.ID: + //fix 如果是自己 直接查看 + break case req.User != nil && req.User.IsAdmin: break case post.Visibility == core.PostVisitPublic: