Monorepo for Tangled tangled.org

be consistent about using Did instead of DID

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

anirudh.fi da205ebc 76bb6d31

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