Load user account repos correctly

This commit is contained in:
Melon 2022-04-11 18:58:51 +01:00
parent 426c956d45
commit ccf4318310
Signed by: melon
GPG Key ID: B0ADD5395BCDAAB6
3 changed files with 8 additions and 3 deletions

2
go.mod
View File

@ -4,6 +4,7 @@ go 1.18
require (
code.gitea.io/sdk/gitea v0.15.1
github.com/bwmarrin/discordgo v0.24.0
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1
@ -12,7 +13,6 @@ require (
)
require (
github.com/bwmarrin/discordgo v0.24.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect

View File

@ -94,7 +94,12 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util
q := req.URL.Query()
if q.Has("org") {
selOrg = q.Get("org")
repos, _, err := giteaClient.ListOrgRepos(selOrg, gitea.ListOrgReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}})
var repos []*gitea.Repository
if selOrg == "@me" {
repos, _, err = giteaClient.ListMyRepos(gitea.ListReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}})
} else {
repos, _, err = giteaClient.ListOrgRepos(selOrg, gitea.ListOrgReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}})
}
if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
return

View File

@ -28,7 +28,7 @@
<p>Select repository source:</p>
<ul>
<li>
<a href="?org={{.Username}}">{{.Username}} (my user account)</a>
<a href="?org=@me">{{.Username}} (my user account)</a>
</li>
{{range .Orgs}}
<li>