mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-05 18:05:19 +02:00
Bug fixes for repo permissions in API
Also move duplicated code into repo.APIFormat(..)
This commit is contained in:
parent
08b9af9ad8
commit
04b9a7e7a2
7 changed files with 45 additions and 26 deletions
|
@ -277,8 +277,13 @@ func (repo *Repository) HTMLURL() string {
|
|||
|
||||
// APIFormat converts a Repository to api.Repository
|
||||
// Arguments that are allowed to be nil: permission
|
||||
func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
|
||||
func (repo *Repository) APIFormat(mode AccessMode) *api.Repository {
|
||||
cloneLink := repo.CloneLink()
|
||||
permission := &api.Permission{
|
||||
Admin: mode >= AccessModeAdmin,
|
||||
Push: mode >= AccessModeWrite,
|
||||
Pull: mode >= AccessModeRead,
|
||||
}
|
||||
return &api.Repository{
|
||||
ID: repo.ID,
|
||||
Owner: repo.Owner.APIFormat(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue