Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commits pushed with deploy keys not shown in dashboard #24521

Merged
merged 6 commits into from
May 10, 2023

Conversation

Zettat123
Copy link
Contributor

@Zettat123 Zettat123 commented May 4, 2023

Fix #21324

In the current logic, if the Actor user is not an admin user, all activities from private organizations won't be shown even if the Actor user is a member of the organization.

As mentioned in the issue, when using deploy key to make a commit and push, the activity's act_user_id will be the id of the organization so the activity won't be shown to non-admin users because the visibility of the organization is private.

if opts.Actor == nil {
cond = cond.And(builder.In("act_user_id",
builder.Select("`user`.id").Where(
builder.Eq{"keep_activity_private": false, "visibility": structs.VisibleTypePublic},
).From("`user`"),
))
} else if !opts.Actor.IsAdmin {
cond = cond.And(builder.In("act_user_id",
builder.Select("`user`.id").Where(
builder.Eq{"keep_activity_private": false}.
And(builder.In("visibility", structs.VisibleTypePublic, structs.VisibleTypeLimited))).
Or(builder.Eq{"id": opts.Actor.ID}).From("`user`"),
))
}

This PR improves this logic so the activities of private organizations can be shown.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 4, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 4, 2023
models/activities/action.go Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 5, 2023
@wxiaoguang
Copy link
Contributor

Haven't tested, I have a question:

Is the new SQL friendly to action table? The action table could be pretty large.

@Zettat123
Copy link
Contributor Author

Is the new SQL friendly to action table? The action table could be pretty large.

Yes, the action table may be large. But the query logic doesn't change, we always need a cond.And(builder.In("act_user_id", uidCond)) to select the action.act_user_id. I only improved the uidCond and fixed some missing user.id.

@Zettat123 Zettat123 requested a review from lunny May 5, 2023 10:01
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 9, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 10, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 10, 2023
@lunny lunny enabled auto-merge (squash) May 10, 2023 03:55
@lunny lunny merged commit 29637b0 into go-gitea:main May 10, 2023
@GiteaBot GiteaBot added this to the 1.20.0 milestone May 10, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 10, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 10, 2023
* upstream/main:
  Remove unnecessary code (go-gitea#24610)
  Fix commits pushed with deploy keys not shown in dashboard (go-gitea#24521)
  fix: release page for empty or non-existing target (go-gitea#24470)
  Filter get single commit (go-gitea#24613)
  Attach a tooltip to the action status icon (go-gitea#24614)
  Use official Vue extension in Gitpod (go-gitea#24609)
  Create a branch directly from commit on the create branch API (go-gitea#22956)
  Make repository response support HTTP range request (go-gitea#24592)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Commits pushed with deploy keys not shown in owner/member dashboard
6 participants