Monorepo for Tangled tangled.org

appview: use less OwnerSlashRepo() in handlers #802

merged opened by boltless.me targeting master from sl/yurolxtlpsmz
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3m5mgmc446w22
+70 -86
Interdiff #0 #1
+4 -4
appview/issues/issues.go
··· 312 312 // notify about the issue closure 313 313 rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 314 314 315 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 315 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 316 316 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) 317 317 return 318 318 } else { ··· 363 363 // notify about the issue reopen 364 364 rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 365 365 366 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 366 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 367 367 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) 368 368 return 369 369 } else { ··· 468 468 } 469 469 rp.notifier.NewIssueComment(r.Context(), &comment, mentions) 470 470 471 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 471 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 472 472 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d#comment-%d", ownerSlashRepo, issue.IssueId, commentId)) 473 473 } 474 474 ··· 974 974 } 975 975 rp.notifier.NewIssue(r.Context(), issue, mentions) 976 976 977 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 977 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 978 978 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) 979 979 return 980 980 }
+1 -1
appview/middleware/middleware.go
··· 327 327 return 328 328 } 329 329 330 - fullName := mw.repoResolver.GetBaseRepoPath(r, &f.Repo) 330 + fullName := reporesolver.GetBaseRepoPath(r, &f.Repo) 331 331 332 332 if r.Header.Get("User-Agent") == "Go-http-client/1.1" { 333 333 if r.URL.Query().Get("go-get") == "1" {
appview/pages/repoinfo/repoinfo.go

This file has not been changed.

+16 -16
appview/pulls/pulls.go
··· 267 267 r.Context(), 268 268 &xrpcc, 269 269 &tangled.RepoMergeCheck_Input{ 270 - Did: f.OwnerDid(), 270 + Did: f.Did, 271 271 Name: f.Name, 272 272 Branch: pull.TargetBranch, 273 273 Patch: patch, ··· 381 381 } else { 382 382 // pulls within the same repo 383 383 knot = f.Knot 384 - ownerDid = f.OwnerDid() 384 + ownerDid = f.Did 385 385 repoName = f.Name 386 386 } 387 387 ··· 800 800 } 801 801 s.notifier.NewPullComment(r.Context(), comment, mentions) 802 802 803 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 803 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 804 804 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d#comment-%d", ownerSlashRepo, pull.PullId, commentId)) 805 805 return 806 806 } ··· 825 825 Host: host, 826 826 } 827 827 828 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 828 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 829 829 xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 830 830 if err != nil { 831 831 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 990 990 Host: host, 991 991 } 992 992 993 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 993 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 994 994 xrpcBytes, err := tangled.RepoCompare(r.Context(), xrpcc, repo, targetBranch, sourceBranch) 995 995 if err != nil { 996 996 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 1272 1272 1273 1273 s.notifier.NewPull(r.Context(), pull) 1274 1274 1275 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 1275 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 1276 1276 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pullId)) 1277 1277 } 1278 1278 ··· 1374 1374 return 1375 1375 } 1376 1376 1377 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 1377 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 1378 1378 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls", ownerSlashRepo)) 1379 1379 } 1380 1380 ··· 1434 1434 Host: host, 1435 1435 } 1436 1436 1437 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 1437 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 1438 1438 xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 1439 1439 if err != nil { 1440 1440 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 1555 1555 Host: targetHost, 1556 1556 } 1557 1557 1558 - targetRepo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 1558 + targetRepo := fmt.Sprintf("%s/%s", f.Did, f.Name) 1559 1559 targetXrpcBytes, err := tangled.RepoBranches(r.Context(), targetXrpcc, "", 0, targetRepo) 1560 1560 if err != nil { 1561 1561 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 1686 1686 Host: host, 1687 1687 } 1688 1688 1689 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 1689 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 1690 1690 xrpcBytes, err := tangled.RepoCompare(r.Context(), xrpcc, repo, pull.TargetBranch, pull.PullSource.Branch) 1691 1691 if err != nil { 1692 1692 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 1923 1923 return 1924 1924 } 1925 1925 1926 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 1926 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 1927 1927 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pull.PullId)) 1928 1928 } 1929 1929 ··· 2117 2117 return 2118 2118 } 2119 2119 2120 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 2120 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 2121 2121 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pull.PullId)) 2122 2122 } 2123 2123 ··· 2171 2171 2172 2172 authorName := ident.Handle.String() 2173 2173 mergeInput := &tangled.RepoMerge_Input{ 2174 - Did: f.OwnerDid(), 2174 + Did: f.Did, 2175 2175 Name: f.Name, 2176 2176 Branch: pull.TargetBranch, 2177 2177 Patch: patch, ··· 2236 2236 s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2237 2237 } 2238 2238 2239 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 2239 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 2240 2240 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pull.PullId)) 2241 2241 } 2242 2242 ··· 2309 2309 s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2310 2310 } 2311 2311 2312 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 2312 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 2313 2313 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pull.PullId)) 2314 2314 } 2315 2315 ··· 2383 2383 s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2384 2384 } 2385 2385 2386 - ownerSlashRepo := s.repoResolver.GetBaseRepoPath(r, &f.Repo) 2386 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 2387 2387 s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", ownerSlashRepo, pull.PullId)) 2388 2388 } 2389 2389
+4 -4
appview/repo/blob.go
··· 54 54 xrpcc := &indigoxrpc.Client{ 55 55 Host: host, 56 56 } 57 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Repo.Name) 57 + repo := fmt.Sprintf("%s/%s", f.Did, f.Repo.Name) 58 58 resp, err := tangled.RepoBlob(r.Context(), xrpcc, filePath, false, ref, repo) 59 59 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 60 60 l.Error("failed to call XRPC repo.blob", "err", xrpcerr) ··· 62 62 return 63 63 } 64 64 65 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 65 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 66 66 67 67 // Use XRPC response directly instead of converting to internal types 68 68 var breadcrumbs [][]string ··· 107 107 if !rp.config.Core.Dev { 108 108 scheme = "https" 109 109 } 110 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Repo.Name) 110 + repo := fmt.Sprintf("%s/%s", f.Did, f.Repo.Name) 111 111 baseURL := &url.URL{ 112 112 Scheme: scheme, 113 113 Host: f.Knot, ··· 258 258 scheme = "https" 259 259 } 260 260 261 - repoName := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 261 + repoName := fmt.Sprintf("%s/%s", f.Did, f.Name) 262 262 baseURL := &url.URL{ 263 263 Scheme: scheme, 264 264 Host: f.Knot,
+2 -2
appview/repo/tree.go
··· 39 39 xrpcc := &indigoxrpc.Client{ 40 40 Host: host, 41 41 } 42 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 42 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 43 43 xrpcResp, err := tangled.RepoTree(r.Context(), xrpcc, treePath, ref, repo) 44 44 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 45 45 l.Error("failed to call XRPC repo.tree", "err", xrpcerr) ··· 79 79 result.ReadmeFileName = xrpcResp.Readme.Filename 80 80 result.Readme = xrpcResp.Readme.Contents 81 81 } 82 - ownerSlashRepo := rp.repoResolver.GetBaseRepoPath(r, &f.Repo) 82 + ownerSlashRepo := reporesolver.GetBaseRepoPath(r, &f.Repo) 83 83 // redirects tree paths trying to access a blob; in this case the result.Files is unpopulated, 84 84 // so we can safely redirect to the "parent" (which is the same file). 85 85 if len(result.Files) == 0 && result.Parent == treePath {
+4 -26
appview/reporesolver/resolver.go
··· 12 12 "strings" 13 13 14 14 "github.com/bluesky-social/indigo/atproto/identity" 15 - securejoin "github.com/cyphar/filepath-securejoin" 16 15 "github.com/go-chi/chi/v5" 17 16 "tangled.org/core/appview/config" 18 17 "tangled.org/core/appview/db" ··· 45 44 } 46 45 47 46 // NOTE: this... should not even be here. the entire package will be removed in future refactor 48 - func (rr *RepoResolver) GetBaseRepoPath(r *http.Request, repo *models.Repo) string { 47 + func GetBaseRepoPath(r *http.Request, repo *models.Repo) string { 49 48 var ( 50 49 user = chi.URLParam(r, "user") 51 50 name = chi.URLParam(r, "repo") ··· 81 80 }, nil 82 81 } 83 82 84 - func (f *ResolvedRepo) OwnerDid() string { 85 - return f.OwnerId.DID.String() 86 - } 87 - 88 - func (f *ResolvedRepo) OwnerHandle() string { 89 - return f.OwnerId.Handle.String() 90 - } 91 - 92 - func (f *ResolvedRepo) OwnerSlashRepo() string { 93 - handle := f.OwnerId.Handle 94 - 95 - var p string 96 - if handle != "" && !handle.IsInvalidHandle() { 97 - p, _ = securejoin.SecureJoin(fmt.Sprintf("@%s", handle), f.Name) 98 - } else { 99 - p, _ = securejoin.SecureJoin(f.OwnerDid(), f.Name) 100 - } 101 - 102 - return p 103 - } 104 - 105 83 func (f *ResolvedRepo) Collaborators(ctx context.Context) ([]pages.Collaborator, error) { 106 84 repoCollaborators, err := f.rr.enforcer.E.GetImplicitUsersForResourceByDomain(f.DidSlashRepo(), f.Knot) 107 85 if err != nil { ··· 180 158 knot := f.Knot 181 159 182 160 repoInfo := repoinfo.RepoInfo{ 183 - OwnerDid: f.OwnerDid(), 184 - OwnerHandle: f.OwnerHandle(), 161 + OwnerDid: f.OwnerId.DID.String(), 162 + OwnerHandle: f.OwnerId.Handle.String(), 185 163 Name: f.Name, 186 - Rkey: f.Repo.Rkey, 164 + Rkey: f.Rkey, 187 165 RepoAt: repoAt, 188 166 Description: f.Description, 189 167 Website: f.Website,
+1 -1
appview/repo/artifact.go
··· 305 305 Host: host, 306 306 } 307 307 308 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 308 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 309 309 xrpcBytes, err := tangled.RepoTags(ctx, xrpcc, "", 0, repo) 310 310 if err != nil { 311 311 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+1 -1
appview/repo/branches.go
··· 29 29 xrpcc := &indigoxrpc.Client{ 30 30 Host: host, 31 31 } 32 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 32 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 33 33 xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 34 34 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 35 35 l.Error("failed to call XRPC repo.branches", "err", xrpcerr)
+2 -2
appview/repo/compare.go
··· 36 36 Host: host, 37 37 } 38 38 39 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 39 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 40 40 branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 41 41 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 42 42 l.Error("failed to call XRPC repo.branches", "err", xrpcerr) ··· 147 147 Host: host, 148 148 } 149 149 150 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 150 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 151 151 152 152 branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 153 153 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+23 -17
appview/repo/feed.go
··· 11 11 "tangled.org/core/appview/db" 12 12 "tangled.org/core/appview/models" 13 13 "tangled.org/core/appview/pagination" 14 - "tangled.org/core/appview/reporesolver" 15 14 15 + "github.com/bluesky-social/indigo/atproto/identity" 16 16 "github.com/bluesky-social/indigo/atproto/syntax" 17 17 "github.com/gorilla/feeds" 18 18 ) 19 19 20 - func (rp *Repo) getRepoFeed(ctx context.Context, f *reporesolver.ResolvedRepo) (*feeds.Feed, error) { 20 + func (rp *Repo) getRepoFeed(ctx context.Context, repo *models.Repo, ownerSlashRepo string) (*feeds.Feed, error) { 21 21 const feedLimitPerType = 100 22 22 23 - pulls, err := db.GetPullsWithLimit(rp.db, feedLimitPerType, db.FilterEq("repo_at", f.RepoAt())) 23 + pulls, err := db.GetPullsWithLimit(rp.db, feedLimitPerType, db.FilterEq("repo_at", repo.RepoAt())) 24 24 if err != nil { 25 25 return nil, err 26 26 } ··· 28 28 issues, err := db.GetIssuesPaginated( 29 29 rp.db, 30 30 pagination.Page{Limit: feedLimitPerType}, 31 - db.FilterEq("repo_at", f.RepoAt()), 31 + db.FilterEq("repo_at", repo.RepoAt()), 32 32 ) 33 33 if err != nil { 34 34 return nil, err 35 35 } 36 36 37 37 feed := &feeds.Feed{ 38 - Title: fmt.Sprintf("activity feed for %s", f.OwnerSlashRepo()), 39 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s", rp.config.Core.AppviewHost, f.OwnerSlashRepo()), Type: "text/html", Rel: "alternate"}, 38 + Title: fmt.Sprintf("activity feed for @%s", ownerSlashRepo), 39 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s", rp.config.Core.AppviewHost, ownerSlashRepo), Type: "text/html", Rel: "alternate"}, 40 40 Items: make([]*feeds.Item, 0), 41 41 Updated: time.UnixMilli(0), 42 42 } 43 43 44 44 for _, pull := range pulls { 45 - items, err := rp.createPullItems(ctx, pull, f) 45 + items, err := rp.createPullItems(ctx, pull, repo, ownerSlashRepo) 46 46 if err != nil { 47 47 return nil, err 48 48 } ··· 50 50 } 51 51 52 52 for _, issue := range issues { 53 - item, err := rp.createIssueItem(ctx, issue, f) 53 + item, err := rp.createIssueItem(ctx, issue, repo, ownerSlashRepo) 54 54 if err != nil { 55 55 return nil, err 56 56 } ··· 71 71 return feed, nil 72 72 } 73 73 74 - func (rp *Repo) createPullItems(ctx context.Context, pull *models.Pull, f *reporesolver.ResolvedRepo) ([]*feeds.Item, error) { 74 + func (rp *Repo) createPullItems(ctx context.Context, pull *models.Pull, repo *models.Repo, ownerSlashRepo string) ([]*feeds.Item, error) { 75 75 owner, err := rp.idResolver.ResolveIdent(ctx, pull.OwnerDid) 76 76 if err != nil { 77 77 return nil, err ··· 80 80 var items []*feeds.Item 81 81 82 82 state := rp.getPullState(pull) 83 - description := rp.buildPullDescription(owner.Handle, state, pull, f.OwnerSlashRepo()) 83 + description := rp.buildPullDescription(owner.Handle, state, pull, ownerSlashRepo) 84 84 85 85 mainItem := &feeds.Item{ 86 86 Title: fmt.Sprintf("[PR #%d] %s", pull.PullId, pull.Title), 87 87 Description: description, 88 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), pull.PullId)}, 88 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d", rp.config.Core.AppviewHost, ownerSlashRepo, pull.PullId)}, 89 89 Created: pull.Created, 90 90 Author: &feeds.Author{Name: fmt.Sprintf("@%s", owner.Handle)}, 91 91 } ··· 98 98 99 99 roundItem := &feeds.Item{ 100 100 Title: fmt.Sprintf("[PR #%d] %s (round #%d)", pull.PullId, pull.Title, round.RoundNumber), 101 - Description: fmt.Sprintf("@%s submitted changes (at round #%d) on PR #%d in %s", owner.Handle, round.RoundNumber, pull.PullId, f.OwnerSlashRepo()), 102 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d/round/%d/", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), pull.PullId, round.RoundNumber)}, 101 + Description: fmt.Sprintf("@%s submitted changes (at round #%d) on PR #%d in @%s", owner.Handle, round.RoundNumber, pull.PullId, ownerSlashRepo), 102 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d/round/%d/", rp.config.Core.AppviewHost, ownerSlashRepo, pull.PullId, round.RoundNumber)}, 103 103 Created: round.Created, 104 104 Author: &feeds.Author{Name: fmt.Sprintf("@%s", owner.Handle)}, 105 105 } ··· 109 109 return items, nil 110 110 } 111 111 112 - func (rp *Repo) createIssueItem(ctx context.Context, issue models.Issue, f *reporesolver.ResolvedRepo) (*feeds.Item, error) { 112 + func (rp *Repo) createIssueItem(ctx context.Context, issue models.Issue, repo *models.Repo, ownerSlashRepo string) (*feeds.Item, error) { 113 113 owner, err := rp.idResolver.ResolveIdent(ctx, issue.Did) 114 114 if err != nil { 115 115 return nil, err ··· 122 122 123 123 return &feeds.Item{ 124 124 Title: fmt.Sprintf("[Issue #%d] %s", issue.IssueId, issue.Title), 125 - Description: fmt.Sprintf("@%s %s issue #%d in %s", owner.Handle, state, issue.IssueId, f.OwnerSlashRepo()), 126 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/issues/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), issue.IssueId)}, 125 + Description: fmt.Sprintf("@%s %s issue #%d in @%s", owner.Handle, state, issue.IssueId, ownerSlashRepo), 126 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/issues/%d", rp.config.Core.AppviewHost, ownerSlashRepo, issue.IssueId)}, 127 127 Created: issue.Created, 128 128 Author: &feeds.Author{Name: fmt.Sprintf("@%s", owner.Handle)}, 129 129 }, nil ··· 152 152 log.Println("failed to fully resolve repo:", err) 153 153 return 154 154 } 155 + repoOwnerId, ok := r.Context().Value("resolvedId").(identity.Identity) 156 + if !ok || repoOwnerId.Handle.IsInvalidHandle() { 157 + log.Println("failed to get resolved repo owner id") 158 + return 159 + } 160 + ownerSlashRepo := repoOwnerId.Handle.String() + "/" + f.Name 155 161 156 - feed, err := rp.getRepoFeed(r.Context(), f) 162 + feed, err := rp.getRepoFeed(r.Context(), &f.Repo, ownerSlashRepo) 157 163 if err != nil { 158 164 log.Println("failed to get repo feed:", err) 159 165 rp.pages.Error500(w)
+2 -2
appview/repo/index.go
··· 179 179 180 180 if err != nil || langs == nil { 181 181 // non-fatal, fetch langs from ks via XRPC 182 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 182 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 183 183 ls, err := tangled.RepoLanguages(ctx, xrpcc, currentRef, repo) 184 184 if err != nil { 185 185 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { ··· 256 256 257 257 // buildIndexResponse creates a RepoIndexResponse by combining multiple xrpc calls in parallel 258 258 func (rp *Repo) buildIndexResponse(ctx context.Context, xrpcc *indigoxrpc.Client, f *reporesolver.ResolvedRepo, ref string) (*types.RepoIndexResponse, error) { 259 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 259 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 260 260 261 261 // first get branches to determine the ref if not specified 262 262 branchesBytes, err := tangled.RepoBranches(ctx, xrpcc, "", 0, repo)
+2 -2
appview/repo/log.go
··· 57 57 cursor = strconv.Itoa(offset) 58 58 } 59 59 60 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 60 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 61 61 xrpcBytes, err := tangled.RepoLog(r.Context(), xrpcc, cursor, limit, "", ref, repo) 62 62 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 63 63 l.Error("failed to call XRPC repo.log", "err", xrpcerr) ··· 174 174 Host: host, 175 175 } 176 176 177 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 177 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 178 178 xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, repo) 179 179 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 180 180 l.Error("failed to call XRPC repo.diff", "err", xrpcerr)
+5 -5
appview/repo/repo.go
··· 864 864 r.Context(), 865 865 client, 866 866 &tangled.RepoDelete_Input{ 867 - Did: f.OwnerDid(), 867 + Did: f.Did, 868 868 Name: f.Name, 869 869 Rkey: f.Rkey, 870 870 }, ··· 902 902 l.Info("removed collaborators") 903 903 904 904 // remove repo RBAC 905 - err = rp.enforcer.RemoveRepo(f.OwnerDid(), f.Knot, f.DidSlashRepo()) 905 + err = rp.enforcer.RemoveRepo(f.Did, f.Knot, f.DidSlashRepo()) 906 906 if err != nil { 907 907 rp.pages.Notice(w, noticeId, "Failed to update RBAC rules") 908 908 return 909 909 } 910 910 911 911 // remove repo from db 912 - err = db.RemoveRepo(tx, f.OwnerDid(), f.Name) 912 + err = db.RemoveRepo(tx, f.Did, f.Name) 913 913 if err != nil { 914 914 rp.pages.Notice(w, noticeId, "Failed to update appview") 915 915 return ··· 930 930 return 931 931 } 932 932 933 - rp.pages.HxRedirect(w, fmt.Sprintf("/%s", f.OwnerDid())) 933 + rp.pages.HxRedirect(w, fmt.Sprintf("/%s", f.Did)) 934 934 } 935 935 936 936 func (rp *Repo) SyncRepoFork(w http.ResponseWriter, r *http.Request) { ··· 1058 1058 uri = "http" 1059 1059 } 1060 1060 1061 - forkSourceUrl := fmt.Sprintf("%s://%s/%s/%s", uri, f.Knot, f.OwnerDid(), f.Repo.Name) 1061 + forkSourceUrl := fmt.Sprintf("%s://%s/%s/%s", uri, f.Knot, f.Did, f.Repo.Name) 1062 1062 l = l.With("cloneUrl", forkSourceUrl) 1063 1063 1064 1064 sourceAt := f.RepoAt().String()
+2 -2
appview/repo/settings.go
··· 194 194 Host: host, 195 195 } 196 196 197 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 197 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 198 198 xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 199 199 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 200 200 l.Error("failed to call XRPC repo.branches", "err", xrpcerr) ··· 292 292 user := rp.oauth.GetUser(r) 293 293 294 294 // all spindles that the repo owner is a member of 295 - spindles, err := rp.enforcer.GetSpindlesForUser(f.OwnerDid()) 295 + spindles, err := rp.enforcer.GetSpindlesForUser(f.Did) 296 296 if err != nil { 297 297 l.Error("failed to fetch spindles", "err", err) 298 298 return
+1 -1
appview/repo/tags.go
··· 31 31 xrpcc := &indigoxrpc.Client{ 32 32 Host: host, 33 33 } 34 - repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name) 34 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 35 35 xrpcBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo) 36 36 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 37 37 l.Error("failed to call XRPC repo.tags", "err", xrpcerr)

History

6 rounds 1 comment
sign up or login to add to the discussion
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
expand 0 comments
pull request successfully merged
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
expand 0 comments
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
expand 0 comments
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
appview: use less OwnerSlashRepo() in handlers
1/3 failed, 2/3 timeout
expand
expand 1 comment

The end goal here is to remove the RepoInfo and ResolvedRepo