+11
-3
appview/state/state.go
+11
-3
appview/state/state.go
···
12
"time"
13
14
comatproto "github.com/bluesky-social/indigo/api/atproto"
15
lexutil "github.com/bluesky-social/indigo/lex/util"
16
"github.com/gliderlabs/ssh"
17
"github.com/go-chi/chi/v5"
···
28
db *db.DB
29
auth *auth.Auth
30
enforcer *rbac.Enforcer
31
}
32
33
func Make() (*State, error) {
···
47
return nil, err
48
}
49
50
-
return &State{db, auth, enforcer}, nil
51
}
52
53
func (s *State) Login(w http.ResponseWriter, r *http.Request) {
···
202
resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
203
Collection: tangled.PublicKeyNSID,
204
Repo: did,
205
-
Rkey: uuid.New().String(),
206
Record: &lexutil.LexiconTypeDecoder{
207
Val: &tangled.PublicKey{
208
Created: time.Now().Format(time.RFC3339),
···
411
resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
412
Collection: tangled.KnotMemberNSID,
413
Repo: currentUser.Did,
414
-
Rkey: uuid.New().String(),
415
Record: &lexutil.LexiconTypeDecoder{
416
Val: &tangled.KnotMember{
417
Member: memberIdent.DID.String(),
···
12
"time"
13
14
comatproto "github.com/bluesky-social/indigo/api/atproto"
15
+
"github.com/bluesky-social/indigo/atproto/syntax"
16
lexutil "github.com/bluesky-social/indigo/lex/util"
17
"github.com/gliderlabs/ssh"
18
"github.com/go-chi/chi/v5"
···
29
db *db.DB
30
auth *auth.Auth
31
enforcer *rbac.Enforcer
32
+
tidClock *syntax.TIDClock
33
}
34
35
func Make() (*State, error) {
···
49
return nil, err
50
}
51
52
+
clock := syntax.NewTIDClock(0)
53
+
54
+
return &State{db, auth, enforcer, clock}, nil
55
+
}
56
+
57
+
func (s *State) TID() string {
58
+
return s.tidClock.Next().String()
59
}
60
61
func (s *State) Login(w http.ResponseWriter, r *http.Request) {
···
210
resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
211
Collection: tangled.PublicKeyNSID,
212
Repo: did,
213
+
Rkey: s.TID(),
214
Record: &lexutil.LexiconTypeDecoder{
215
Val: &tangled.PublicKey{
216
Created: time.Now().Format(time.RFC3339),
···
419
resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
420
Collection: tangled.KnotMemberNSID,
421
Repo: currentUser.Did,
422
+
Rkey: s.TID(),
423
Record: &lexutil.LexiconTypeDecoder{
424
Val: &tangled.KnotMember{
425
Member: memberIdent.DID.String(),