this repo has no description

be consistent about using Did instead of DID

As much as possible. The atproto libs aren't themselves consistent about this.

Changed files
+17 -17
appview
auth
state
cmd
repoguard
knotserver
+1 -1
appview/auth/auth.go
··· 178 return a.Store.Get(r, appview.SessionName) 179 } 180 181 - func (a *Auth) GetDID(r *http.Request) string { 182 clientSession, err := a.Store.Get(r, appview.SessionName) 183 if err != nil || clientSession.IsNew { 184 return ""
··· 178 return a.Store.Get(r, appview.SessionName) 179 } 180 181 + func (a *Auth) GetDid(r *http.Request) string { 182 clientSession, err := a.Store.Get(r, appview.SessionName) 183 if err != nil || clientSession.IsNew { 184 return ""
+1 -1
appview/state/state.go
··· 154 log.Println("unimplemented") 155 return 156 case http.MethodPut: 157 - did := s.auth.GetDID(r) 158 key := r.FormValue("key") 159 name := r.FormValue("name") 160 client, _ := s.auth.AuthorizedClient(r)
··· 154 log.Println("unimplemented") 155 return 156 case http.MethodPut: 157 + did := s.auth.GetDid(r) 158 key := r.FormValue("key") 159 name := r.FormValue("name") 160 client, _ := s.auth.AuthorizedClient(r)
+2 -2
cmd/repoguard/main.go
··· 65 66 // example.com/repo 67 handlePath := strings.Trim(cmdParts[1], "'") 68 - repoName := handleToDID(handlePath) 69 70 validCommands := map[string]bool{ 71 "git-receive-pack": true, ··· 111 }) 112 } 113 114 - func handleToDID(handlePath string) string { 115 handle := path.Dir(handlePath) 116 117 ident, err := auth.ResolveIdent(context.Background(), handle)
··· 65 66 // example.com/repo 67 handlePath := strings.Trim(cmdParts[1], "'") 68 + repoName := handleToDid(handlePath) 69 70 validCommands := map[string]bool{ 71 "git-receive-pack": true, ··· 111 }) 112 } 113 114 + func handleToDid(handlePath string) string { 115 handle := path.Dir(handlePath) 116 117 ident, err := auth.ResolveIdent(context.Background(), handle)
+4 -4
knotserver/db/known_dids.go
··· 1 package db 2 3 - func (d *DB) AddDID(did string) error { 4 _, err := d.db.Exec(`insert into known_dids (did) values (?)`, did) 5 return err 6 } 7 8 - func (d *DB) RemoveDID(did string) error { 9 _, err := d.db.Exec(`delete from known_dids where did = ?`, did) 10 return err 11 } 12 13 - func (d *DB) GetAllDIDs() ([]string, error) { 14 var dids []string 15 16 rows, err := d.db.Query(`select did from known_dids`) ··· 34 return dids, nil 35 } 36 37 - func (d *DB) HasKnownDIDs() bool { 38 var count int 39 err := d.db.QueryRow(`select count(*) from known_dids`).Scan(&count) 40 if err != nil {
··· 1 package db 2 3 + func (d *DB) AddDid(did string) error { 4 _, err := d.db.Exec(`insert into known_dids (did) values (?)`, did) 5 return err 6 } 7 8 + func (d *DB) RemoveDid(did string) error { 9 _, err := d.db.Exec(`delete from known_dids where did = ?`, did) 10 return err 11 } 12 13 + func (d *DB) GetAllDids() ([]string, error) { 14 var dids []string 15 16 rows, err := d.db.Query(`select did from known_dids`) ··· 34 return dids, nil 35 } 36 37 + func (d *DB) HasKnownDids() bool { 38 var count int 39 err := d.db.QueryRow(`select count(*) from known_dids`).Scan(&count) 40 if err != nil {
+3 -3
knotserver/handler.go
··· 39 return nil, fmt.Errorf("failed to start jetstream: %w", err) 40 } 41 42 - // Check if the knot knows about any DIDs; 43 // if it does, it is already initialized and we can repopulate the 44 // Jetstream subscriptions. 45 - dids, err := db.GetAllDIDs() 46 if err != nil { 47 - return nil, fmt.Errorf("failed to get all DIDs: %w", err) 48 } 49 if len(dids) > 0 { 50 h.knotInitialized = true
··· 39 return nil, fmt.Errorf("failed to start jetstream: %w", err) 40 } 41 42 + // Check if the knot knows about any Dids; 43 // if it does, it is already initialized and we can repopulate the 44 // Jetstream subscriptions. 45 + dids, err := db.GetAllDids() 46 if err != nil { 47 + return nil, fmt.Errorf("failed to get all Dids: %w", err) 48 } 49 if len(dids) > 0 { 50 h.knotInitialized = true
+1 -1
knotserver/jsclient/jetstream.go
··· 47 j.triggerReconnect() 48 } 49 50 - // UpdateDids updates the DIDs list and triggers a reconnection 51 func (j *JetstreamClient) UpdateDids(dids []string) { 52 j.mu.Lock() 53 j.dids = dids
··· 47 j.triggerReconnect() 48 } 49 50 + // UpdateDids updates the Dids list and triggers a reconnection 51 func (j *JetstreamClient) UpdateDids(dids []string) { 52 j.mu.Lock() 53 j.dids = dids
+5 -5
knotserver/routes.go
··· 369 370 func (h *Handle) NewRepo(w http.ResponseWriter, r *http.Request) { 371 data := struct { 372 - DID string `json:"did"` 373 Name string `json:"name"` 374 }{} 375 ··· 378 return 379 } 380 381 - did := data.DID 382 name := data.Name 383 384 repoPath := filepath.Join(h.c.Repo.ScanPath, did, name) ··· 399 } 400 401 data := struct { 402 - DID string `json:"did"` 403 PublicKey string `json:"key"` 404 Created string `json:"created"` 405 }{} ··· 409 return 410 } 411 412 - did := data.DID 413 key := data.PublicKey 414 created := data.Created 415 ··· 428 return 429 } 430 431 - if err := h.db.AddDID(did); err == nil { 432 pk := db.PublicKey{ 433 Did: did, 434 }
··· 369 370 func (h *Handle) NewRepo(w http.ResponseWriter, r *http.Request) { 371 data := struct { 372 + Did string `json:"did"` 373 Name string `json:"name"` 374 }{} 375 ··· 378 return 379 } 380 381 + did := data.Did 382 name := data.Name 383 384 repoPath := filepath.Join(h.c.Repo.ScanPath, did, name) ··· 399 } 400 401 data := struct { 402 + Did string `json:"did"` 403 PublicKey string `json:"key"` 404 Created string `json:"created"` 405 }{} ··· 409 return 410 } 411 412 + did := data.Did 413 key := data.PublicKey 414 created := data.Created 415 ··· 428 return 429 } 430 431 + if err := h.db.AddDid(did); err == nil { 432 pk := db.PublicKey{ 433 Did: did, 434 }