Skip to content

Commit 2db0ffe

Browse files
appleboylunny
authored andcommitted
fix: User can see the private activity on public activity history. (#818)
1 parent ea8c8cd commit 2db0ffe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

routers/user/profile.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ func Profile(ctx *context.Context) {
7878
ctx.Data["Title"] = ctxUser.DisplayName()
7979
ctx.Data["PageIsUserProfile"] = true
8080
ctx.Data["Owner"] = ctxUser
81+
showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID)
8182

82-
orgs, err := models.GetOrgsByUserID(ctxUser.ID, ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID))
83+
orgs, err := models.GetOrgsByUserID(ctxUser.ID, showPrivate)
8384
if err != nil {
8485
ctx.Handle(500, "GetOrgsByUserIDDesc", err)
8586
return
@@ -91,13 +92,12 @@ func Profile(ctx *context.Context) {
9192
ctx.Data["TabName"] = tab
9293
switch tab {
9394
case "activity":
94-
retrieveFeeds(ctx, ctxUser, -1, 0, true)
95+
retrieveFeeds(ctx, ctxUser, -1, 0, !showPrivate)
9596
if ctx.Written() {
9697
return
9798
}
9899
case "stars":
99-
showPrivateRepos := ctx.IsSigned && ctx.User.ID == ctxUser.ID
100-
starredRepos, err := ctxUser.GetStarredRepos(showPrivateRepos)
100+
starredRepos, err := ctxUser.GetStarredRepos(showPrivate)
101101
if err != nil {
102102
ctx.Handle(500, "GetStarredRepos", err)
103103
return
@@ -109,7 +109,7 @@ func Profile(ctx *context.Context) {
109109
page = 1
110110
}
111111

112-
ctx.Data["Repos"], err = models.GetUserRepositories(ctxUser.ID, ctx.IsSigned && ctx.User.ID == ctxUser.ID, page, setting.UI.User.RepoPagingNum)
112+
ctx.Data["Repos"], err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum)
113113
if err != nil {
114114
ctx.Handle(500, "GetRepositories", err)
115115
return

0 commit comments

Comments
 (0)