Add markdown event descriptions for hosts to provide context
Hosts can now add a free-form description (with markdown rendering via goldmark) when creating or editing events. Descriptions render safely with no raw HTML passthrough. Includes ALTER TABLE migration for existing databases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-8
@@ -17,14 +17,15 @@ type Claim struct {
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
ID int64
|
||||
Slug string
|
||||
Title string
|
||||
Date string
|
||||
Time string
|
||||
Location string
|
||||
AdminToken string
|
||||
CreatedAt time.Time
|
||||
ID int64
|
||||
Slug string
|
||||
Title string
|
||||
Date string
|
||||
Time string
|
||||
Location string
|
||||
AdminToken string
|
||||
Description string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Rsvp struct {
|
||||
|
||||
+5
-2
@@ -5,10 +5,13 @@ SELECT * FROM events WHERE slug = ?;
|
||||
SELECT * FROM events WHERE admin_token = ?;
|
||||
|
||||
-- name: CreateEvent :one
|
||||
INSERT INTO events (slug, title, date, time, location, admin_token)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO events (slug, title, date, time, location, admin_token, description)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateEventDescription :exec
|
||||
UPDATE events SET description = ? WHERE id = ?;
|
||||
|
||||
-- name: UpdateEvent :exec
|
||||
UPDATE events SET title = ?, date = ?, time = ?, location = ? WHERE id = ?;
|
||||
|
||||
|
||||
+30
-11
@@ -57,18 +57,19 @@ func (q *Queries) CreateClaim(ctx context.Context, arg CreateClaimParams) (Claim
|
||||
}
|
||||
|
||||
const createEvent = `-- name: CreateEvent :one
|
||||
INSERT INTO events (slug, title, date, time, location, admin_token)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING id, slug, title, date, time, location, admin_token, created_at
|
||||
INSERT INTO events (slug, title, date, time, location, admin_token, description)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id, slug, title, date, time, location, admin_token, description, created_at
|
||||
`
|
||||
|
||||
type CreateEventParams struct {
|
||||
Slug string
|
||||
Title string
|
||||
Date string
|
||||
Time string
|
||||
Location string
|
||||
AdminToken string
|
||||
Slug string
|
||||
Title string
|
||||
Date string
|
||||
Time string
|
||||
Location string
|
||||
AdminToken string
|
||||
Description string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error) {
|
||||
@@ -79,6 +80,7 @@ func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event
|
||||
arg.Time,
|
||||
arg.Location,
|
||||
arg.AdminToken,
|
||||
arg.Description,
|
||||
)
|
||||
var i Event
|
||||
err := row.Scan(
|
||||
@@ -89,6 +91,7 @@ func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event
|
||||
&i.Time,
|
||||
&i.Location,
|
||||
&i.AdminToken,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
@@ -190,7 +193,7 @@ func (q *Queries) DeleteSlot(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
const getEventByAdminToken = `-- name: GetEventByAdminToken :one
|
||||
SELECT id, slug, title, date, time, location, admin_token, created_at FROM events WHERE admin_token = ?
|
||||
SELECT id, slug, title, date, time, location, admin_token, description, created_at FROM events WHERE admin_token = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetEventByAdminToken(ctx context.Context, adminToken string) (Event, error) {
|
||||
@@ -204,13 +207,14 @@ func (q *Queries) GetEventByAdminToken(ctx context.Context, adminToken string) (
|
||||
&i.Time,
|
||||
&i.Location,
|
||||
&i.AdminToken,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getEventBySlug = `-- name: GetEventBySlug :one
|
||||
SELECT id, slug, title, date, time, location, admin_token, created_at FROM events WHERE slug = ?
|
||||
SELECT id, slug, title, date, time, location, admin_token, description, created_at FROM events WHERE slug = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetEventBySlug(ctx context.Context, slug string) (Event, error) {
|
||||
@@ -224,6 +228,7 @@ func (q *Queries) GetEventBySlug(ctx context.Context, slug string) (Event, error
|
||||
&i.Time,
|
||||
&i.Location,
|
||||
&i.AdminToken,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
@@ -406,6 +411,20 @@ func (q *Queries) UpdateEvent(ctx context.Context, arg UpdateEventParams) error
|
||||
return err
|
||||
}
|
||||
|
||||
const updateEventDescription = `-- name: UpdateEventDescription :exec
|
||||
UPDATE events SET description = ? WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateEventDescriptionParams struct {
|
||||
Description string
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateEventDescription(ctx context.Context, arg UpdateEventDescriptionParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateEventDescription, arg.Description, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateSlot = `-- name: UpdateSlot :exec
|
||||
UPDATE slots SET name = ?, emoji = ?, max_claims = ? WHERE id = ?
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user