From 84282c608cdb4ea5006d2b2f81f7d97c631a2b87 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 15 Jan 2024 15:07:10 +0800 Subject: [PATCH] Fix when private user following user, private user will not be counted in his own view (#28037) (#28792) Backport #28037 by @yp05327 Doer: asdasasdasasdasasdasasdasasdasasdasasdas (private user) Followed: TestUser (public user) Before: (From doer's view) ![image](https://github.com/go-gitea/gitea/assets/18380374/9ba16b3b-068c-43c5-a3dd-e3343b5b32f2) (From followed user's view, can see doer) ![image](https://github.com/go-gitea/gitea/assets/18380374/dfd1b564-d689-4393-b3d3-1e6bf52c94ba) After: (From doer's view) ![image](https://github.com/go-gitea/gitea/assets/18380374/1c85c1d1-c9f7-40c8-948c-145f7cae9a04) Co-authored-by: yp05327 <576951401@qq.com> --- models/user/user.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/user/user.go b/models/user/user.go index 63b95816c..2c4e94953 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1205,6 +1205,8 @@ func isUserVisibleToViewerCond(viewer *User) builder.Cond { return builder.Neq{ "`user`.visibility": structs.VisibleTypePrivate, }.Or( + // viewer self + builder.Eq{"`user`.id": viewer.ID}, // viewer's following builder.In("`user`.id", builder.