You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/models
Jason Song a33e74d40d
Clarify Actions resources ownership (#31724)
Fix #31707.

Also related to #31715.

Some Actions resources could has different types of ownership. It could
be:

- global: all repos and orgs/users can use it.
- org/user level: only the org/user can use it.
- repo level: only the repo can use it.

There are two ways to distinguish org/user level from repo level:
1. `{owner_id: 1, repo_id: 2}` for repo level, and `{owner_id: 1,
repo_id: 0}` for org level.
2. `{owner_id: 0, repo_id: 2}` for repo level, and `{owner_id: 1,
repo_id: 0}` for org level.

The first way seems more reasonable, but it may not be true. The point
is that although a resource, like a runner, belongs to a repo (it can be
used by the repo), the runner doesn't belong to the repo's org (other
repos in the same org cannot use the runner). So, the second method
makes more sense.

And the first way is not user-friendly to query, we must set the repo id
to zero to avoid wrong results.

So, #31715 should be right. And the most simple way to fix #31707 is
just:

```diff
-	shared.GetRegistrationToken(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.ID)
+	shared.GetRegistrationToken(ctx, 0, ctx.Repo.Repository.ID)
```

However, it is quite intuitive to set both owner id and repo id since
the repo belongs to the owner. So I prefer to be compatible with it. If
we get both owner id and repo id not zero when creating or finding, it's
very clear that the caller want one with repo level, but set owner id
accidentally. So it's OK to accept it but fix the owner id to zero.
6 months ago
..
actions Clarify Actions resources ownership (#31724) 6 months ago
activities Refactor webhook (#31587) 7 months ago
admin Next round of `db.DefaultContext` refactor (#27089) 1 year ago
asymkey Enable more `revive` linter rules (#30608) 9 months ago
auth add skip secondary authorization option for public oauth2 clients (#31454) 7 months ago
avatars Replace 10 more gt- classes with tw- (#29945) 11 months ago
db [Refactor] Unify repo search order by logic (#30876) 8 months ago
dbfs Enable `unparam` linter (#31277) 8 months ago
fixtures Fix wrong display of recently pushed notification (#25812) 8 months ago
git Exclude protected branches from recently pushed (#31748) 6 months ago
issues Add permission check when creating PR (#31033) 6 months ago
migrations add skip secondary authorization option for public oauth2 clients (#31454) 7 months ago
organization Fix wrong display of recently pushed notification (#25812) 8 months ago
packages Fix package list performance (#30520) 10 months ago
perm Clarify permission "HasAccess" behavior (#30585) 10 months ago
project Fix the display of project type for deleted projects (#31732) 6 months ago
pull Add support for sha256 repositories (#23894) 1 year ago
repo Make GetRepositoryByName more safer (#31712) 6 months ago
secret Clarify Actions resources ownership (#31724) 6 months ago
shared/types Refactor locale&string&template related code (#29165) 12 months ago
system Refactor deletion (#28610) 1 year ago
unit Refactor repo unit "disabled" check (#31389) 8 months ago
unittest Add some tests to clarify the "must-change-password" behavior (#30693) 9 months ago
user Support delete user email in admin panel (#31690) 6 months ago
webhook Store webhook event in database (#29145) 11 months ago
error.go Add merge style `fast-forward-only` (#28954) 12 months ago
fixture_generation.go Replace more db.DefaultContext (#27628) 1 year ago
fixture_test.go Replace more db.DefaultContext (#27628) 1 year ago
main_test.go make writing main test easier (#27270) 1 year ago
org.go Add user blocking (#29028) 11 months ago
org_team.go Clarify permission "HasAccess" behavior (#30585) 10 months ago
org_team_test.go Add user blocking (#29028) 11 months ago
org_test.go Add user blocking (#29028) 11 months ago
repo.go Refactor deletion (#28610) 1 year ago
repo_test.go Penultimate round of `db.DefaultContext` refactor (#27414) 1 year ago
repo_transfer.go chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621) 9 months ago