From ccf4318310f0f8348a4844660948607468d18f4a Mon Sep 17 00:00:00 2001 From: MrMelon Date: Mon, 11 Apr 2022 18:58:51 +0100 Subject: [PATCH] Load user account repos correctly --- go.mod | 2 +- module/gitea/main.go | 7 ++++++- module/gitea/pages/index.go.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6a688c5..5fa95e3 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/module/gitea/main.go b/module/gitea/main.go index c6bfdbd..a5b35d0 100644 --- a/module/gitea/main.go +++ b/module/gitea/main.go @@ -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 diff --git a/module/gitea/pages/index.go.html b/module/gitea/pages/index.go.html index 5118e11..0efa997 100644 --- a/module/gitea/pages/index.go.html +++ b/module/gitea/pages/index.go.html @@ -28,7 +28,7 @@

Select repository source: