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