forked from tangled.org/core
this repo has no description

appview/models: move db.PublicKey into models

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 775ea4d7 07f809fc

verified
Changed files
+35 -28
appview
commitverify
db
models
pages
+2 -1
appview/commitverify/verify.go
···
"github.com/go-git/go-git/v5/plumbing/object"
"tangled.org/core/appview/db"
+
"tangled.org/core/appview/models"
"tangled.org/core/crypto"
"tangled.org/core/types"
)
···
func GetVerifiedCommits(e db.Execer, emailToDid map[string]string, ndCommits []types.NiceDiff) (VerifiedCommits, error) {
vcs := VerifiedCommits{}
-
didPubkeyCache := make(map[string][]db.PublicKey)
+
didPubkeyCache := make(map[string][]models.PublicKey)
for _, commit := range ndCommits {
c := commit.Commit
+7 -26
appview/db/pubkeys.go
···
package db
import (
-
"encoding/json"
+
"tangled.org/core/appview/models"
"time"
)
···
return err
}
-
type PublicKey struct {
-
Did string `json:"did"`
-
Key string `json:"key"`
-
Name string `json:"name"`
-
Rkey string `json:"rkey"`
-
Created *time.Time
-
}
-
-
func (p PublicKey) MarshalJSON() ([]byte, error) {
-
type Alias PublicKey
-
return json.Marshal(&struct {
-
Created string `json:"created"`
-
*Alias
-
}{
-
Created: p.Created.Format(time.RFC3339),
-
Alias: (*Alias)(&p),
-
})
-
}
-
-
func GetAllPublicKeys(e Execer) ([]PublicKey, error) {
-
var keys []PublicKey
+
func GetAllPublicKeys(e Execer) ([]models.PublicKey, error) {
+
var keys []models.PublicKey
rows, err := e.Query(`select key, name, did, rkey, created from public_keys`)
if err != nil {
···
defer rows.Close()
for rows.Next() {
-
var publicKey PublicKey
+
var publicKey models.PublicKey
var createdAt string
if err := rows.Scan(&publicKey.Key, &publicKey.Name, &publicKey.Did, &publicKey.Rkey, &createdAt); err != nil {
return nil, err
···
return keys, nil
}
-
func GetPublicKeysForDid(e Execer, did string) ([]PublicKey, error) {
-
var keys []PublicKey
+
func GetPublicKeysForDid(e Execer, did string) ([]models.PublicKey, error) {
+
var keys []models.PublicKey
rows, err := e.Query(`select did, key, name, rkey, created from public_keys where did = ?`, did)
if err != nil {
···
defer rows.Close()
for rows.Next() {
-
var publicKey PublicKey
+
var publicKey models.PublicKey
var createdAt string
if err := rows.Scan(&publicKey.Did, &publicKey.Key, &publicKey.Name, &publicKey.Rkey, &createdAt); err != nil {
return nil, err
+25
appview/models/pubkey.go
···
+
package models
+
+
import (
+
"encoding/json"
+
"time"
+
)
+
+
type PublicKey struct {
+
Did string `json:"did"`
+
Key string `json:"key"`
+
Name string `json:"name"`
+
Rkey string `json:"rkey"`
+
Created *time.Time
+
}
+
+
func (p PublicKey) MarshalJSON() ([]byte, error) {
+
type Alias PublicKey
+
return json.Marshal(&struct {
+
Created string `json:"created"`
+
*Alias
+
}{
+
Created: p.Created.Format(time.RFC3339),
+
Alias: (*Alias)(&p),
+
})
+
}
+1 -1
appview/pages/pages.go
···
type UserKeysSettingsParams struct {
LoggedInUser *oauth.User
-
PubKeys []db.PublicKey
+
PubKeys []models.PublicKey
Tabs []map[string]any
Tab string
}