1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: trusted_and_blocked_users.sql
package data
import (
"context"
"crypto/ed25519"
"github.com/kyren223/eko/pkg/snowflake"
)
const getTrustedPublicKey = `-- name: GetTrustedPublicKey :one
SELECT trusted_public_key FROM trusted_users
WHERE trusting_user_id = ? AND trusted_user_id = ?
`
type GetTrustedPublicKeyParams struct {
TrustingUserID snowflake.ID
TrustedUserID snowflake.ID
}
func (q *Queries) GetTrustedPublicKey(ctx context.Context, arg GetTrustedPublicKeyParams) (ed25519.PublicKey, error) {
row := q.db.QueryRowContext(ctx, getTrustedPublicKey, arg.TrustingUserID, arg.TrustedUserID)
var trusted_public_key ed25519.PublicKey
err := row.Scan(&trusted_public_key)
return trusted_public_key, err
}
const getUserTrusteds = `-- name: GetUserTrusteds :many
SELECT trusted_user_id, trusted_public_key FROM trusted_users
WHERE trusting_user_id = ?
`
type GetUserTrustedsRow struct {
TrustedUserID snowflake.ID
TrustedPublicKey ed25519.PublicKey
}
func (q *Queries) GetUserTrusteds(ctx context.Context, trustingUserID snowflake.ID) ([]GetUserTrustedsRow, error) {
rows, err := q.db.QueryContext(ctx, getUserTrusteds, trustingUserID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetUserTrustedsRow
for rows.Next() {
var i GetUserTrustedsRow
if err := rows.Scan(&i.TrustedUserID, &i.TrustedPublicKey); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const trustUser = `-- name: TrustUser :exec
INSERT OR IGNORE INTO trusted_users (
trusting_user_id, trusted_user_id, trusted_public_key
) VALUES (?, ?, ?)
`
type TrustUserParams struct {
TrustingUserID snowflake.ID
TrustedUserID snowflake.ID
TrustedPublicKey ed25519.PublicKey
}
func (q *Queries) TrustUser(ctx context.Context, arg TrustUserParams) error {
_, err := q.db.ExecContext(ctx, trustUser, arg.TrustingUserID, arg.TrustedUserID, arg.TrustedPublicKey)
return err
}
const untrustUser = `-- name: UntrustUser :exec
DELETE FROM trusted_users
WHERE trusting_user_id = ? AND trusted_user_id = ?
`
type UntrustUserParams struct {
TrustingUserID snowflake.ID
TrustedUserID snowflake.ID
}
func (q *Queries) UntrustUser(ctx context.Context, arg UntrustUserParams) error {
_, err := q.db.ExecContext(ctx, untrustUser, arg.TrustingUserID, arg.TrustedUserID)
return err
}
|