Add public GET /v1/whitelist/pubkeys for active subscriber pubkeys
Expose JSON array of hex pubkeys backed by ListActivePubkeys query. Includes OpenAPI documentation and integration tests. Made-with: Love
This commit is contained in:
@@ -50,6 +50,24 @@ func (r *Repo) ActiveByName(ctx context.Context) (map[string]string, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (r *Repo) ListActivePubkeys(ctx context.Context) ([]string, error) {
|
||||
rows, err := r.db.QueryContext(ctx,
|
||||
`SELECT pubkey FROM users WHERE is_active = 1 ORDER BY pubkey`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
out := make([]string, 0)
|
||||
for rows.Next() {
|
||||
var pk string
|
||||
if err := rows.Scan(&pk); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, pk)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (r *Repo) collect(rows interface {
|
||||
Next() bool
|
||||
Scan(...any) error
|
||||
|
||||
Reference in New Issue
Block a user