aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-04-30 04:13:58 +0900
committerGitHub <noreply@github.com>2023-04-29 15:13:58 -0400
commitcc64a925602d54f3439dd19f16b5280bd0377a7a (patch)
tree36b9d91bee60fe8e71a6aaaf2a40fac3f554d46e /models
parent94d6b5b09d49b2622c2164a03cfae45dced96c74 (diff)
downloadgitea-cc64a925602d54f3439dd19f16b5280bd0377a7a.tar.gz
gitea-cc64a925602d54f3439dd19f16b5280bd0377a7a.zip
Add follow organization and fix the logic of following page (#24345)
![image](https://user-images.githubusercontent.com/18380374/234740589-066f2e5c-30c7-4fc3-a539-066100e1f138.png) ![image](https://user-images.githubusercontent.com/18380374/234740605-88efe55d-7eaa-422e-ab86-0b5a402ca11c.png) Maybe we can fix user card tmpl in #24319? Or maybe a list is better here ![image](https://user-images.githubusercontent.com/18380374/234451417-7f93df20-4b19-4abb-a62d-4c67e1aa2220.png) --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/user/user.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/models/user/user.go b/models/user/user.go
index 053d6680cd..46c4440e5f 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -346,7 +346,7 @@ func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListO
Select("`user`.*").
Join("LEFT", "follow", "`user`.id=follow.follow_id").
Where("follow.user_id=?", u.ID).
- And("`user`.type=?", UserTypeIndividual).
+ And("`user`.type IN (?, ?)", UserTypeIndividual, UserTypeOrganization).
And(isUserVisibleToViewerCond(viewer))
if listOptions.Page != 0 {
@@ -1210,23 +1210,25 @@ func isUserVisibleToViewerCond(viewer *User) builder.Cond {
return builder.Neq{
"`user`.visibility": structs.VisibleTypePrivate,
}.Or(
+ // viewer's following
builder.In("`user`.id",
builder.
Select("`follow`.user_id").
From("follow").
Where(builder.Eq{"`follow`.follow_id": viewer.ID})),
+ // viewer's org user
builder.In("`user`.id",
builder.
Select("`team_user`.uid").
From("team_user").
- Join("INNER", "`team_user` AS t2", "`team_user`.id = `t2`.id").
+ Join("INNER", "`team_user` AS t2", "`team_user`.org_id = `t2`.org_id").
Where(builder.Eq{"`t2`.uid": viewer.ID})),
+ // viewer's org
builder.In("`user`.id",
builder.
- Select("`team_user`.uid").
+ Select("`team_user`.org_id").
From("team_user").
- Join("INNER", "`team_user` AS t2", "`team_user`.org_id = `t2`.org_id").
- Where(builder.Eq{"`t2`.uid": viewer.ID})))
+ Where(builder.Eq{"`team_user`.uid": viewer.ID})))
}
// IsUserVisibleToViewer check if viewer is able to see user profile