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 import ( 4 "context" 5 6 "tangled.org/core/appview/db" 7 "tangled.org/core/appview/models" 8 "tangled.org/core/appview/oauth" ··· 11 12 // GetRepoInfo converts given `Repo` to `RepoInfo` object. 13 // The `user` can be nil. 14 - func (s *Service) GetRepoInfo(ctx context.Context, baseRepo *models.Repo, user *oauth.User) (*repoinfo.RepoInfo, error) { 15 var ( 16 repoAt = baseRepo.RepoAt() 17 isStarred = false ··· 55 repoInfo := &repoinfo.RepoInfo{ 56 // ok this is basically a models.Repo 57 OwnerDid: baseRepo.Did, 58 - OwnerHandle: "", // TODO: shouldn't use 59 Name: baseRepo.Name, 60 Rkey: baseRepo.Rkey, 61 Description: baseRepo.Description, ··· 69 Source: sourceRepo, 70 71 // repo path (context) 72 - CurrentDir: "", 73 - Ref: "", 74 75 // info related to the session 76 IsStarred: isStarred,
··· 3 import ( 4 "context" 5 6 + "github.com/bluesky-social/indigo/atproto/identity" 7 "tangled.org/core/appview/db" 8 "tangled.org/core/appview/models" 9 "tangled.org/core/appview/oauth" ··· 12 13 // GetRepoInfo converts given `Repo` to `RepoInfo` object. 14 // The `user` can be nil. 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) { 24 var ( 25 repoAt = baseRepo.RepoAt() 26 isStarred = false ··· 64 repoInfo := &repoinfo.RepoInfo{ 65 // ok this is basically a models.Repo 66 OwnerDid: baseRepo.Did, 67 + OwnerHandle: ownerId.Handle.String(), // TODO: shouldn't use 68 Name: baseRepo.Name, 69 Rkey: baseRepo.Rkey, 70 Description: baseRepo.Description, ··· 78 Source: sourceRepo, 79 80 // repo path (context) 81 + CurrentDir: currentDir, 82 + Ref: ref, 83 84 // info related to the session 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 p.Error503(w) 26 return 27 } 28 29 query := r.URL.Query() 30 searchOpts := models.IssueSearchOptions{ ··· 44 // render page 45 err = func() error { 46 user := session.UserFromContext(ctx) 47 - repoinfo, err := rs.GetRepoInfo(ctx, repo, user) 48 if err != nil { 49 return err 50 }
··· 25 p.Error503(w) 26 return 27 } 28 + repoOwnerId, ok := request.OwnerFromContext(ctx) 29 + if !ok { 30 + l.Error("malformed request") 31 + p.Error503(w) 32 + return 33 + } 34 35 query := r.URL.Query() 36 searchOpts := models.IssueSearchOptions{ ··· 50 // render page 51 err = func() error { 52 user := session.UserFromContext(ctx) 53 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, repo, "", "", user) 54 if err != nil { 55 return err 56 }
+7 -1
appview/web/handler/user_repo_issues_issue.go
··· 24 p.Error503(w) 25 return 26 } 27 28 // render 29 err := func() error { 30 user := session.UserFromContext(ctx) 31 - repoinfo, err := rs.GetRepoInfo(ctx, issue.Repo, user) 32 if err != nil { 33 l.Error("failed to load repo", "err", err) 34 return err
··· 24 p.Error503(w) 25 return 26 } 27 + repoOwnerId, ok := request.OwnerFromContext(ctx) 28 + if !ok { 29 + l.Error("malformed request") 30 + p.Error503(w) 31 + return 32 + } 33 34 // render 35 err := func() error { 36 user := session.UserFromContext(ctx) 37 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, issue.Repo, "", "", user) 38 if err != nil { 39 l.Error("failed to load repo", "err", err) 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 p.Error503(w) 23 return 24 } 25 26 // render 27 err := func() error { 28 user := session.UserFromContext(ctx) 29 - repoinfo, err := rs.GetRepoInfo(ctx, issue.Repo, user) 30 if err != nil { 31 return err 32 }
··· 22 p.Error503(w) 23 return 24 } 25 + repoOwnerId, ok := request.OwnerFromContext(ctx) 26 + if !ok { 27 + l.Error("malformed request") 28 + p.Error503(w) 29 + return 30 + } 31 32 // render 33 err := func() error { 34 user := session.UserFromContext(ctx) 35 + repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, issue.Repo, "", "", user) 36 if err != nil { 37 return err 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 if !ok { 26 return fmt.Errorf("malformed request") 27 } 28 - repoinfo, err := rs.GetRepoInfo(ctx, repo, user) 29 if err != nil { 30 return err 31 }
··· 25 if !ok { 26 return fmt.Errorf("malformed request") 27 } 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) 33 if err != nil { 34 return err 35 }
appview/web/middleware/auth.go

This file has not been changed.

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