Add Twitter video support and use sql.Null[T] for nullable columns

- Store Twitter video URLs in embed_video_url column instead of downloading
- Play videos directly from Twitter's CDN in <video> element
- Fix Twitter API parsing (content_type/url fields)
- Strip t.co URLs from tweet text descriptions
- Use sql.Null[T] generic type for nullable DB columns
- Add Nullable[T] and Ptr[T] helper functions
- Add play indicator overlay for video items in grid
- Add migration for embed_video_url column
This commit is contained in:
soup 2026-01-17 01:23:32 -05:00
parent cdcc5b5293
commit 2887d9c430
Signed by: soup
SSH key fingerprint: SHA256:GYxje8eQkJ6HZKzVWDdyOUF1TyDiprruGhE0Ym8qYDY
8 changed files with 226 additions and 120 deletions

View file

@ -118,13 +118,13 @@ func HandleCreateItem(rc *RequestContext, w http.ResponseWriter, r *http.Request
defer cancel()
it, err := item.QCreate(ctx, rc.DB, item.CreateParams{
Title: req.Title,
Description: req.Description,
LinkURL: req.LinkURL,
Title: item.Nullable(req.Title),
Description: item.Nullable(req.Description),
LinkURL: item.Nullable(req.LinkURL),
ItemType: req.ItemType,
EmbedProvider: req.EmbedProvider,
EmbedVideoID: req.EmbedVideoID,
EmbedHTML: req.EmbedHTML,
EmbedProvider: item.Nullable(req.EmbedProvider),
EmbedVideoID: item.Nullable(req.EmbedVideoID),
EmbedHTML: item.Nullable(req.EmbedHTML),
})
if err != nil {
return err
@ -173,9 +173,9 @@ func HandleUpdateItem(rc *RequestContext, w http.ResponseWriter, r *http.Request
}
if err := item.QUpdate(ctx, rc.DB, it.ID, item.UpdateParams{
Title: req.Title,
Description: req.Description,
LinkURL: req.LinkURL,
Title: item.Nullable(req.Title),
Description: item.Nullable(req.Description),
LinkURL: item.Nullable(req.LinkURL),
}); err != nil {
return err
}
@ -241,11 +241,11 @@ func buildItemResponse(ctx context.Context, rc *RequestContext, it item.Row) (it
resp := itemResponse{
ID: it.PubID,
Title: it.Title,
Description: it.Description,
LinkURL: it.LinkURL,
Title: item.Ptr(it.Title),
Description: item.Ptr(it.Description),
LinkURL: item.Ptr(it.LinkURL),
ItemType: it.ItemType,
EmbedHTML: it.EmbedHTML,
EmbedHTML: item.Ptr(it.EmbedHTML),
Tags: tagNames,
CreatedAt: it.CreatedAt.Format(time.RFC3339),
}