@@ -122,6 +122,8 @@ type profileContributionRepo struct { |
| 122 | 122 | Repo reposdb.Repo |
| 123 | 123 | OwnerSlug string |
| 124 | 124 | AllowIdentityFallback bool |
| 125 | + IsPrivate bool |
| 126 | + IsProfileOwnedPublic bool |
| 125 | 127 | } |
| 126 | 128 | |
| 127 | 129 | func (h *Handlers) visibleUserRepos(ctx context.Context, userID int64, viewer middleware.CurrentUser) []reposdb.Repo { |
@@ -296,7 +298,7 @@ func (h *Handlers) contributionCalendar(ctx context.Context, user usersdb.User, |
| 296 | 298 | if !source.Repo.CreatedAt.Valid || created.Before(windowStart) || !created.Before(windowEnd) { |
| 297 | 299 | continue |
| 298 | 300 | } |
| 299 | | - if source.Repo.OwnerUserID.Int64 != user.ID || source.Repo.Visibility != reposdb.RepoVisibilityPublic { |
| 301 | + if !source.IsProfileOwnedPublic { |
| 300 | 302 | continue |
| 301 | 303 | } |
| 302 | 304 | activity.addCreatedRepo(created, source) |
@@ -370,7 +372,7 @@ func newProfileActivityBuilder() *profileActivityBuilder { |
| 370 | 372 | } |
| 371 | 373 | |
| 372 | 374 | func (b *profileActivityBuilder) addCommit(day time.Time, source profileContributionRepo) { |
| 373 | | - isPrivate := source.Repo.Visibility == reposdb.RepoVisibilityPrivate |
| 375 | + isPrivate := source.IsPrivate |
| 374 | 376 | fullName := source.OwnerSlug + "/" + source.Repo.Name |
| 375 | 377 | url := "/" + url.PathEscape(source.OwnerSlug) + "/" + url.PathEscape(source.Repo.Name) |
| 376 | 378 | if isPrivate { |
@@ -600,15 +602,15 @@ func (h *Handlers) addProfileThreadActivity(ctx context.Context, user usersdb.Us |
| 600 | 602 | } |
| 601 | 603 | deps := policy.Deps{Pool: h.d.Pool} |
| 602 | 604 | for _, row := range rows { |
| 603 | | - if row.Visibility == issuesdb.RepoVisibilityPrivate && !user.IncludePrivateContributions { |
| 604 | | - continue |
| 605 | | - } |
| 606 | 605 | ref := policy.RepoRef{ |
| 607 | 606 | ID: row.RepoID, |
| 608 | 607 | OwnerUserID: row.OwnerUserID.Int64, |
| 609 | 608 | OwnerOrgID: row.OwnerOrgID.Int64, |
| 610 | 609 | Visibility: string(row.Visibility), |
| 611 | 610 | } |
| 611 | + if ref.IsPrivate() && !user.IncludePrivateContributions { |
| 612 | + continue |
| 613 | + } |
| 612 | 614 | if !policy.IsVisibleTo(ctx, deps, actor, ref) { |
| 613 | 615 | continue |
| 614 | 616 | } |
@@ -658,6 +660,8 @@ func (h *Handlers) profileContributionRepos(ctx context.Context, user usersdb.Us |
| 658 | 660 | Repo: repo, |
| 659 | 661 | OwnerSlug: ownerSlug, |
| 660 | 662 | AllowIdentityFallback: allowIdentityFallback, |
| 663 | + IsPrivate: repoRef.IsPrivate(), |
| 664 | + IsProfileOwnedPublic: isProfileOwnedPublicRepo(repo, repoRef, user.ID), |
| 661 | 665 | }) |
| 662 | 666 | } |
| 663 | 667 | |
@@ -697,6 +701,11 @@ func (h *Handlers) profileContributionRepos(ctx context.Context, user usersdb.Us |
| 697 | 701 | return out |
| 698 | 702 | } |
| 699 | 703 | |
| 704 | +func isProfileOwnedPublicRepo(repo reposdb.Repo, ref policy.RepoRef, userID int64) bool { |
| 705 | + ownerUserID := repo.OwnerUserID.Int64 |
| 706 | + return ownerUserID == userID && ref.IsPublic() |
| 707 | +} |
| 708 | + |
| 700 | 709 | func selectedContributionYear(query url.Values, currentYear int) int { |
| 701 | 710 | for _, key := range []string{"year", "from"} { |
| 702 | 711 | raw := strings.TrimSpace(query.Get(key)) |