Add polished answer notifications (#1)

Sends a branded Resend email when a question receives its first answer, records accepted and failed sends, and adds collapsed answer editing with cancel behavior.

Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-08-27 06:55:24 +00:00
committed by codegirl007
parent 35c8c9f391
commit 418ef93da5
28 changed files with 827 additions and 74 deletions
+1
View File
@@ -39,6 +39,7 @@ type User struct {
Name string
PasswordHash string
Role string
Email string
AvatarUrl string
State string
CreatedAt string
+54 -38
View File
@@ -24,8 +24,8 @@ func (q *Queries) CountAdmins(ctx context.Context, role string) (int64, error) {
}
const createUser = `-- name: CreateUser :exec
INSERT INTO users (id, username, name, password_hash, role, avatar_url, state, created_at)
VALUES ($1, $2, $3, $4, $5, '', '', $6)
INSERT INTO users (id, username, name, password_hash, role, email, avatar_url, state, created_at)
VALUES ($1, $2, $3, $4, $5, $6, '', '', $7)
`
type CreateUserParams struct {
@@ -34,6 +34,7 @@ type CreateUserParams struct {
Name string
PasswordHash string
Role string
Email string
CreatedAt string
}
@@ -44,13 +45,14 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error {
arg.Name,
arg.PasswordHash,
arg.Role,
arg.Email,
arg.CreatedAt,
)
return err
}
const getUserByID = `-- name: GetUserByID :one
SELECT id, username, name, role, avatar_url, state, created_at
SELECT id, username, name, role, email, avatar_url, state, created_at
FROM users
WHERE id = $1
`
@@ -60,6 +62,7 @@ type GetUserByIDRow struct {
Username string
Name string
Role string
Email string
AvatarUrl string
State string
CreatedAt string
@@ -73,6 +76,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id string) (GetUserByIDRow, e
&i.Username,
&i.Name,
&i.Role,
&i.Email,
&i.AvatarUrl,
&i.State,
&i.CreatedAt,
@@ -81,7 +85,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id string) (GetUserByIDRow, e
}
const getUserByUsername = `-- name: GetUserByUsername :one
SELECT id, username, name, role, avatar_url, state, created_at, password_hash
SELECT id, username, name, role, email, avatar_url, state, created_at, password_hash
FROM users
WHERE username = $1
`
@@ -91,6 +95,7 @@ type GetUserByUsernameRow struct {
Username string
Name string
Role string
Email string
AvatarUrl string
State string
CreatedAt string
@@ -105,6 +110,7 @@ func (q *Queries) GetUserByUsername(ctx context.Context, username string) (GetUs
&i.Username,
&i.Name,
&i.Role,
&i.Email,
&i.AvatarUrl,
&i.State,
&i.CreatedAt,
@@ -127,12 +133,13 @@ func (q *Queries) GetUserRole(ctx context.Context, id string) (string, error) {
}
const listUsers = `-- name: ListUsers :many
SELECT id, username, name, role, avatar_url, state, created_at
SELECT id, username, name, role, email, avatar_url, state, created_at
FROM users
WHERE (
$1 = ''
OR username ILIKE '%' || $1 || '%'
OR name ILIKE '%' || $1 || '%'
OR email ILIKE '%' || $1 || '%'
)
AND (
$2 = ''
@@ -155,6 +162,7 @@ type ListUsersRow struct {
Username string
Name string
Role string
Email string
AvatarUrl string
State string
CreatedAt string
@@ -179,6 +187,7 @@ func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]ListUse
&i.Username,
&i.Name,
&i.Role,
&i.Email,
&i.AvatarUrl,
&i.State,
&i.CreatedAt,
@@ -196,6 +205,46 @@ func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]ListUse
return items, nil
}
const updateUserProfile = `-- name: UpdateUserProfile :exec
UPDATE users
SET state = $1, email = $2
WHERE id = $3
`
type UpdateUserProfileParams struct {
State string
Email string
ID string
}
func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) error {
_, err := q.db.ExecContext(ctx, updateUserProfile, arg.State, arg.Email, arg.ID)
return err
}
const updateUserProfileAndAvatar = `-- name: UpdateUserProfileAndAvatar :exec
UPDATE users
SET state = $1, email = $2, avatar_url = $3
WHERE id = $4
`
type UpdateUserProfileAndAvatarParams struct {
State string
Email string
AvatarUrl string
ID string
}
func (q *Queries) UpdateUserProfileAndAvatar(ctx context.Context, arg UpdateUserProfileAndAvatarParams) error {
_, err := q.db.ExecContext(ctx, updateUserProfileAndAvatar,
arg.State,
arg.Email,
arg.AvatarUrl,
arg.ID,
)
return err
}
const updateUserRole = `-- name: UpdateUserRole :execresult
UPDATE users
SET role = $1
@@ -210,36 +259,3 @@ type UpdateUserRoleParams struct {
func (q *Queries) UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (sql.Result, error) {
return q.db.ExecContext(ctx, updateUserRole, arg.Role, arg.ID)
}
const updateUserState = `-- name: UpdateUserState :exec
UPDATE users
SET state = $1
WHERE id = $2
`
type UpdateUserStateParams struct {
State string
ID string
}
func (q *Queries) UpdateUserState(ctx context.Context, arg UpdateUserStateParams) error {
_, err := q.db.ExecContext(ctx, updateUserState, arg.State, arg.ID)
return err
}
const updateUserStateAndAvatar = `-- name: UpdateUserStateAndAvatar :exec
UPDATE users
SET state = $1, avatar_url = $2
WHERE id = $3
`
type UpdateUserStateAndAvatarParams struct {
State string
AvatarUrl string
ID string
}
func (q *Queries) UpdateUserStateAndAvatar(ctx context.Context, arg UpdateUserStateAndAvatarParams) error {
_, err := q.db.ExecContext(ctx, updateUserStateAndAvatar, arg.State, arg.AvatarUrl, arg.ID)
return err
}