Monorepo for Tangled tangled.org

appview: allow pub key name updating from atproto ingestion #1313

merged opened by willdot.net targeting master from willdot.net/tangled-fork: update-pub-key-name

This should fix https://tangled.org/tangled.org/core/issues/439

Opted to only allow the name to be updated because I wasn't sure on the repercussions of editing the public key and I thought at that point, you may as well just delete the old public key and create a new one.

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mje4njpdae22
+23 -2
Diff #0
+9 -1
appview/db/pubkeys.go
··· 1 1 package db 2 2 3 3 import ( 4 - "tangled.org/core/appview/models" 5 4 "time" 5 + 6 + "tangled.org/core/appview/models" 6 7 ) 7 8 8 9 func AddPublicKey(e Execer, did, name, key, rkey string) error { ··· 13 14 return err 14 15 } 15 16 17 + func UpdatePublicKey(e Execer, did, name, key, rkey string) error { 18 + _, err := e.Exec( 19 + `update public_keys set name = ? where did = ? and key = ? and rkey = ?`, 20 + name, did, key, rkey) 21 + return err 22 + } 23 + 16 24 func DeletePublicKey(e Execer, did, name, key string) error { 17 25 _, err := e.Exec(` 18 26 delete from public_keys
+14 -1
appview/ingester.go
··· 199 199 l = l.With("nsid", e.Commit.Collection) 200 200 201 201 switch e.Commit.Operation { 202 - case jmodels.CommitOperationCreate, jmodels.CommitOperationUpdate: 202 + case jmodels.CommitOperationCreate: 203 203 l.Debug("processing add of pubkey") 204 204 raw := json.RawMessage(e.Commit.Record) 205 205 record := tangled.PublicKey{} ··· 212 212 name := record.Name 213 213 key := record.Key 214 214 err = db.AddPublicKey(i.Db, did, name, key, e.Commit.RKey) 215 + case jmodels.CommitOperationUpdate: 216 + l.Debug("processing update of pubkey") 217 + raw := json.RawMessage(e.Commit.Record) 218 + record := tangled.PublicKey{} 219 + err = json.Unmarshal(raw, &record) 220 + if err != nil { 221 + l.Error("invalid record", "err", err) 222 + return err 223 + } 224 + 225 + name := record.Name 226 + key := record.Key 227 + err = db.UpdatePublicKey(i.Db, did, name, key, e.Commit.RKey) 215 228 case jmodels.CommitOperationDelete: 216 229 l.Debug("processing delete of pubkey") 217 230 err = db.DeletePublicKeyByRkey(i.Db, did, e.Commit.RKey)

History

1 round 1 comment
sign up or login to add to the discussion
willdot.net submitted #0
1 commit
expand
appview: allow pub key name updating from atproto ingestion
expand 1 comment
pull request successfully merged