Monorepo for Tangled tangled.org

draft: appview: service layer #800

open opened by boltless.me targeting master from sl/uvpzuszrulvq

Obviously file naming of appview/web/handler/*.go files are directly against to go convention. Though I think flattening all handler files can significantly reduce the effort involved in file naming and structuring. We are already grouping core services by domains, and doing same for web handers is just over-complicating.

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3m5jyyj76xa22
+39 -11
Interdiff #6 #7
appview/oauth/handler.go

This file has not been changed.

appview/oauth/session.go

This file has not been changed.

appview/service/issue/errors.go

This file has not been changed.

appview/service/issue/issue.go

This file has not been changed.

appview/service/issue/state.go

This file has not been changed.

appview/service/repo/errors.go

This file has not been changed.

appview/service/repo/repo.go

This file has not been changed.

+13 -4
appview/service/repo/repoinfo.go
··· 3 3 import ( 4 4 "context" 5 5 6 + "github.com/bluesky-social/indigo/atproto/identity" 6 7 "tangled.org/core/appview/db" 7 8 "tangled.org/core/appview/models" 8 9 "tangled.org/core/appview/oauth" ··· 11 12 12 13 // GetRepoInfo converts given `Repo` to `RepoInfo` object. 13 14 // The `user` can be nil. 14 - func (s *Service) GetRepoInfo(ctx context.Context, baseRepo *models.Repo, user *oauth.User) (*repoinfo.RepoInfo, error) { 15 + // NOTE: RepoInfo is bad design and should be removed in future. 16 + // avoid using this method if you can. 17 + func (s *Service) GetRepoInfo( 18 + ctx context.Context, 19 + ownerId *identity.Identity, 20 + baseRepo *models.Repo, 21 + currentDir, ref string, 22 + user *oauth.User, 23 + ) (*repoinfo.RepoInfo, error) { 15 24 var ( 16 25 repoAt = baseRepo.RepoAt() 17 26 isStarred = false ··· 55 64 repoInfo := &repoinfo.RepoInfo{ 56 65 // ok this is basically a models.Repo 57 66 OwnerDid: baseRepo.Did, 58 - OwnerHandle: "", // TODO: shouldn't use 67 + OwnerHandle: ownerId.Handle.String(), // TODO: shouldn't use 59 68 Name: baseRepo.Name, 60 69 Rkey: baseRepo.Rkey, 61 70 Description: baseRepo.Description, ··· 69 78 Source: sourceRepo, 70 79 71 80 // repo path (context) 72 - CurrentDir: "", 73 - Ref: "", 81 + CurrentDir: currentDir, 82 + Ref: ref, 74 83 75 84 // info related to the session 76 85 IsStarred: isStarred,
appview/session/context.go

This file has not been changed.

appview/session/session.go

This file has not been changed.

appview/state/legacy_bridge.go

This file has not been changed.

appview/web/handler/oauth_client_metadata.go

This file has not been changed.

appview/web/handler/oauth_jwks.go

This file has not been changed.

+7 -1
appview/web/handler/user_repo_issues.go
··· 25 25 p.Error503(w) 26 26 return 27 27 } 28 + repoOwnerId, ok := request.OwnerFromContext(ctx) 29 + if !ok { 30 + l.Error("malformed request") 31 + p.Error503(w) 32 + return 33 + } 28 34 29 35 query := r.URL.Query() 30 36 searchOpts := models.IssueSearchOptions{ ··· 44 50 // render page 45 51 err = func() error { 46 52 user := session.UserFromContext(ctx) 47 - repoinfo, err := rs.GetRepoInfo(ctx, repo, user) 53 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, repo, "", "", user) 48 54 if err != nil { 49 55 return err 50 56 }
+7 -1
appview/web/handler/user_repo_issues_issue.go
··· 24 24 p.Error503(w) 25 25 return 26 26 } 27 + repoOwnerId, ok := request.OwnerFromContext(ctx) 28 + if !ok { 29 + l.Error("malformed request") 30 + p.Error503(w) 31 + return 32 + } 27 33 28 34 // render 29 35 err := func() error { 30 36 user := session.UserFromContext(ctx) 31 - repoinfo, err := rs.GetRepoInfo(ctx, issue.Repo, user) 37 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, issue.Repo, "", "", user) 32 38 if err != nil { 33 39 l.Error("failed to load repo", "err", err) 34 40 return err
appview/web/handler/user_repo_issues_issue_close.go

This file has not been changed.

+7 -1
appview/web/handler/user_repo_issues_issue_edit.go
··· 22 22 p.Error503(w) 23 23 return 24 24 } 25 + repoOwnerId, ok := request.OwnerFromContext(ctx) 26 + if !ok { 27 + l.Error("malformed request") 28 + p.Error503(w) 29 + return 30 + } 25 31 26 32 // render 27 33 err := func() error { 28 34 user := session.UserFromContext(ctx) 29 - repoinfo, err := rs.GetRepoInfo(ctx, issue.Repo, user) 35 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, issue.Repo, "", "", user) 30 36 if err != nil { 31 37 return err 32 38 }
appview/web/handler/user_repo_issues_issue_reopen.go

This file has not been changed.

+5 -1
appview/web/handler/user_repo_issues_new.go
··· 25 25 if !ok { 26 26 return fmt.Errorf("malformed request") 27 27 } 28 - repoinfo, err := rs.GetRepoInfo(ctx, repo, user) 28 + repoOwnerId, ok := request.OwnerFromContext(ctx) 29 + if !ok { 30 + return fmt.Errorf("malformed request") 31 + } 32 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, repo, "", "", user) 29 33 if err != nil { 30 34 return err 31 35 }
appview/web/middleware/auth.go

This file has not been changed.

-3
appview/web/middleware/ensuredidorhandle.go
··· 21 21 return 22 22 } 23 23 24 - // TODO: run Normalize middleware from here 25 - 26 24 p.Error404(w) 27 - return 28 25 }) 29 26 } 30 27 }
appview/web/middleware/log.go

This file has not been changed.

appview/web/middleware/middleware.go

This file has not been changed.

appview/web/middleware/normalize.go

This file has not been changed.

appview/web/middleware/paginate.go

This file has not been changed.

appview/web/middleware/resolve.go

This file has not been changed.

appview/web/request/context.go

This file has not been changed.

appview/web/routes.go

This file has not been changed.

cmd/appview/main.go

This file has not been changed.

History

14 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 success
expand
merge conflicts detected
expand
  • appview/pages/templates/user/login.html:33
  • appview/state/profile.go:817
  • appview/pages/templates/user/login.html:31
  • appview/pages/templates/user/login.html:93
  • appview/repo/artifact.go:251
  • appview/state/profile.go:528
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 failed
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
1/3 failed, 1/3 timeout, 1/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview: service layer
3/3 failed
expand
expand 0 comments
1 commit
expand
draft: appview: service layer
3/3 failed
expand
expand 0 comments