Signed-off-by: Lewis lewis@tangled.org
+4
-2
knotserver/xrpc/create_repo.go
+4
-2
knotserver/xrpc/create_repo.go
···
128
128
}
129
129
repoDid = prepared.RepoDid
130
130
131
-
if err := h.Db.StoreRepoKey(repoDid, prepared.SigningKeyRaw, actorDid.String(), repoName); err != nil {
131
+
atUri := fmt.Sprintf("at://%s/%s/%s", actorDid, tangled.RepoNSID, data.Rkey)
132
+
if err := h.Db.StoreRepoKey(repoDid, prepared.SigningKeyRaw, actorDid.String(), repoName, atUri); err != nil {
132
133
if strings.Contains(err.Error(), "UNIQUE constraint failed") {
133
134
writeError(w, xrpcerr.GenericError(fmt.Errorf("repository %s already being created", repoName)), http.StatusConflict)
134
135
return
···
180
181
}
181
182
182
183
if data.RepoDid != nil && strings.HasPrefix(*data.RepoDid, "did:web:") {
183
-
if err := h.Db.StoreRepoDidWeb(repoDid, actorDid.String(), repoName); err != nil {
184
+
webAtUri := fmt.Sprintf("at://%s/%s/%s", actorDid, tangled.RepoNSID, data.Rkey)
185
+
if err := h.Db.StoreRepoDidWeb(repoDid, actorDid.String(), repoName, webAtUri); err != nil {
184
186
cleanupAll()
185
187
if strings.Contains(err.Error(), "UNIQUE constraint failed") {
186
188
writeError(w, xrpcerr.GenericError(fmt.Errorf("did:web %s is already in use", repoDid)), http.StatusConflict)
knotserver/xrpc/delete_branch.go
knotserver/xrpc/delete_branch.go
This file has not been changed.
knotserver/xrpc/delete_repo.go
knotserver/xrpc/delete_repo.go
This file has not been changed.
knotserver/xrpc/fork_status.go
knotserver/xrpc/fork_status.go
This file has not been changed.
knotserver/xrpc/fork_sync.go
knotserver/xrpc/fork_sync.go
This file has not been changed.
knotserver/xrpc/merge.go
knotserver/xrpc/merge.go
This file has not been changed.
knotserver/xrpc/merge_check.go
knotserver/xrpc/merge_check.go
This file has not been changed.
knotserver/xrpc/set_default_branch.go
knotserver/xrpc/set_default_branch.go
This file has not been changed.
+28
-4
knotserver/xrpc/xrpc.go
+28
-4
knotserver/xrpc/xrpc.go
···
4
4
"encoding/json"
5
5
"log/slog"
6
6
"net/http"
7
+
"os"
8
+
"path/filepath"
7
9
"strings"
8
10
11
+
securejoin "github.com/cyphar/filepath-securejoin"
12
+
"github.com/go-chi/chi/v5"
9
13
"tangled.org/core/api/tangled"
10
14
"tangled.org/core/idresolver"
11
15
"tangled.org/core/jetstream"
···
15
19
"tangled.org/core/rbac"
16
20
xrpcerr "tangled.org/core/xrpc/errors"
17
21
"tangled.org/core/xrpc/serviceauth"
18
-
19
-
"github.com/go-chi/chi/v5"
20
22
)
21
23
22
24
type Xrpc struct {
···
85
87
)
86
88
}
87
89
88
-
repoPath, _, _, err := x.Db.ResolveRepoDIDOnDisk(x.Config.Repo.ScanPath, repo)
89
-
if err != nil {
90
+
if !strings.Contains(repo, "/") {
91
+
repoPath, _, _, err := x.Db.ResolveRepoDIDOnDisk(x.Config.Repo.ScanPath, repo)
92
+
if err != nil {
93
+
return "", xrpcerr.RepoNotFoundError
94
+
}
95
+
return repoPath, nil
96
+
}
97
+
98
+
parts := strings.SplitN(repo, "/", 2)
99
+
ownerDid, repoName := parts[0], parts[1]
100
+
101
+
repoDid, err := x.Db.GetRepoDid(ownerDid, repoName)
102
+
if err == nil {
103
+
repoPath, _, _, resolveErr := x.Db.ResolveRepoDIDOnDisk(x.Config.Repo.ScanPath, repoDid)
104
+
if resolveErr == nil {
105
+
return repoPath, nil
106
+
}
107
+
}
108
+
109
+
repoPath, joinErr := securejoin.SecureJoin(x.Config.Repo.ScanPath, filepath.Join(ownerDid, repoName))
110
+
if joinErr != nil {
111
+
return "", xrpcerr.RepoNotFoundError
112
+
}
113
+
if _, statErr := os.Stat(repoPath); statErr != nil {
90
114
return "", xrpcerr.RepoNotFoundError
91
115
}
92
116
return repoPath, nil
History
12 rounds
0 comments
oyster.cafe
submitted
#11
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
merge conflicts detected
expand
collapse
expand
collapse
- go.mod:34
- go.sum:339
expand 0 comments
oyster.cafe
submitted
#10
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#9
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#8
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#7
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#6
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#5
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#4
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#3
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#2
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#1
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#0
1 commit
expand
collapse
knotserver/xrpc: use repo DID resolution in all handlers
Signed-off-by: Lewis <lewis@tangled.org>