mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
WIP save point. Server + W2-4/W3-3 complete and gate-green; F3 voice E2EE identity keys + TOFU implemented and MITM-verified-closed; the F3 voice-panel UI (safety-number display, verified/mismatch badge, re-pin modal) is still TODO. - W2-4 attachment link (coverage confirmed); W3-3a XFF CIDR pre-parse; W3-3b update-binary TOCTOU (single-handle verify + O_EXCL staging) - F3 server: migration 017 identity_public_key, PATCH /users/me persist, ready/member_join/user_update carry key, signed voice_e2ee_announce - F3 client: ECDSA identity keypair (keyring + pin store), publish wired into ready, verifyPeerAnnounce pin-before-legacy, rePinPeerIdentity recovery - Gates: server full CI mirror green (-race/-deadlock/lint/4 build tags); client typecheck/lint/format + 3337 vitest green. Rust CI-verify only. Next: build F3 voice-panel UI, then adversarial review, then finalize commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.5 KiB
SQL
45 lines
1.5 KiB
SQL
-- name: GetUserByUsername :one
|
|
SELECT id, username, password, avatar, role_id, totp_secret, status,
|
|
created_at, last_seen, banned, ban_reason, ban_expires, identity_public_key
|
|
FROM users WHERE username = ? COLLATE NOCASE;
|
|
|
|
-- name: GetUserByID :one
|
|
SELECT id, username, password, avatar, role_id, totp_secret, status,
|
|
created_at, last_seen, banned, ban_reason, ban_expires, identity_public_key
|
|
FROM users WHERE id = ?;
|
|
|
|
-- name: CreateUser :execresult
|
|
INSERT INTO users (username, password, role_id) VALUES (?, ?, ?);
|
|
|
|
-- name: UpdateUserStatus :exec
|
|
UPDATE users SET status = ?, last_seen = datetime('now') WHERE id = ?;
|
|
|
|
-- name: UpdateUserTOTPSecret :exec
|
|
UPDATE users SET totp_secret = ? WHERE id = ?;
|
|
|
|
-- name: UpdateUserIdentityKey :exec
|
|
UPDATE users SET identity_public_key = ? WHERE id = ?;
|
|
|
|
-- name: ResetAllUserStatuses :exec
|
|
UPDATE users SET status = 'offline' WHERE status != 'offline';
|
|
|
|
-- name: BanUser :exec
|
|
UPDATE users SET banned = 1, ban_reason = ?, ban_expires = ? WHERE id = ?;
|
|
|
|
-- name: UnbanUser :exec
|
|
UPDATE users SET banned = 0, ban_reason = NULL, ban_expires = NULL WHERE id = ?;
|
|
|
|
-- name: ListMembers :many
|
|
SELECT u.id, u.username, u.avatar, u.status, LOWER(r.name), u.identity_public_key
|
|
FROM users u
|
|
JOIN roles r ON u.role_id = r.id
|
|
WHERE u.banned = 0
|
|
ORDER BY u.username ASC
|
|
LIMIT 1000;
|
|
|
|
-- name: CountUsers :one
|
|
SELECT COUNT(*) FROM users;
|
|
|
|
-- name: CountUsersWithoutTOTP :one
|
|
SELECT COUNT(*) FROM users WHERE banned = 0 AND totp_secret IS NULL;
|