diff --git a/models/activities/action.go b/models/activities/action.go index fc6f7d8dcc..e4336f8d65 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -519,7 +519,7 @@ func activityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder. includePrivateRepos := opts.RequestedUser != nil && opts.RequestedUser.ActionsVisibility.ShowAll() // check readable repositories by doer/actor - if opts.Actor == nil || !includePrivateRepos && !opts.Actor.IsAdmin { + if !includePrivateRepos && !opts.Actor.IsAdmin { cond = cond.And(builder.In("repo_id", repo_model.AccessibleRepoIDsQuery(opts.Actor))) } diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 0f39767586..ead42c4626 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -13,6 +13,7 @@ import ( "strings" "time" + "code.gitea.io/gitea/models/organization" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/markup" @@ -176,6 +177,9 @@ func NewFuncMap() template.FuncMap { "FilenameIsImage": FilenameIsImage, "TabSizeClass": TabSizeClass, + + // org + "IsOrganizationMember": organization.IsOrganizationMember, } } diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 8dcf40a95e..876880bc95 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -74,14 +74,13 @@ func userProfile(ctx *context.Context) { profileDbRepo, profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer) defer profileClose() - showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID || ctx.ContextUser.ActionsVisibility.ShowAll()) - prepareUserProfileTabData(ctx, showPrivate, profileDbRepo, profileGitRepo, profileReadmeBlob) + prepareUserProfileTabData(ctx, profileDbRepo, profileGitRepo, profileReadmeBlob) // call PrepareContextForProfileBigAvatar later to avoid re-querying the NumFollowers & NumFollowing shared_user.PrepareContextForProfileBigAvatar(ctx) ctx.HTML(http.StatusOK, tplProfile) } -func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDbRepo *repo_model.Repository, profileGitRepo *git.Repository, profileReadme *git.Blob) { +func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.Repository, profileGitRepo *git.Repository, profileReadme *git.Blob) { // if there is a profile readme, default to "overview" page, otherwise, default to "repositories" page // if there is not a profile readme, the overview tab should be treated as the repositories tab tab := ctx.FormString("tab") @@ -174,7 +173,7 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb items, count, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{ RequestedUser: ctx.ContextUser, Actor: ctx.Doer, - IncludePrivate: showPrivate, + IncludePrivate: true, OnlyPerformedBy: true, IncludeDeleted: false, Date: date, diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 4d17ac5887..dc9b0c4e59 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -1,6 +1,13 @@
{{range .Feeds}} - {{$isPrivateView := and (not $.IsAdmin) .IsPrivate (ne $.ContextUser.ID $.SignedUserID) (not $.IsOrganizationMember)}} + {{$isPrivateView := and (not $.IsAdmin) .IsPrivate (ne $.ContextUser.ID $.SignedUserID)}} + {{if $isPrivateView}} + {{$isOrganizationMember := $.IsOrganizationMember}} + {{if eq $isOrganizationMember nil}} + {{$isOrganizationMember = IsOrganizationMember ctx .Repo.Owner.ID $.SignedUserID}} + {{end}} + {{$isPrivateView = and $isPrivateView (not $isOrganizationMember)}} + {{end}}
{{ctx.AvatarUtils.AvatarByAction .}}