Add video picker and Discord video attachments.
CI / test (pull_request) Successful in 6m29s

The picker accepts one MP4 or WebM, the thread lightbox zooms photos, and Discord gets the video as a file on a follow-up message so photo embeds still render.
This commit is contained in:
2026-08-31 02:00:56 -07:00
parent 84dea8ea5d
commit f96df3222d
22 changed files with 1018 additions and 144 deletions
+21 -5
View File
@@ -7,8 +7,26 @@ import (
"plumber/internal/store"
)
func (s *Server) publishPostCreated(post, root *store.Post, author *store.User) {
s.publishPost(events.PostCreated{PostEvent: s.postEvent(post, root, author)}, root)
func (s *Server) publishPostCreated(post, root *store.Post, author *store.User, media []events.Media, cleanup func()) {
release := events.Once(func() {
closeHeldMedia(media)
if cleanup != nil {
cleanup()
}
})
if root != nil && root.PostState == store.PostStateHidden {
release()
return
}
ev := events.PostCreated{PostEvent: s.postEvent(post, root, author)}
if s.cfg.HoldUploadUntilDiscord && len(media) > 0 {
ev.Media = media
ev.Release = release
s.cfg.Events.Publish(context.Background(), ev)
return
}
release()
s.cfg.Events.Publish(context.Background(), events.PostCreated{PostEvent: ev.PostEvent})
}
func (s *Server) publishPostUpdated(post, root *store.Post, author *store.User) {
@@ -55,12 +73,10 @@ func (s *Server) postEvent(post, root *store.Post, author *store.User) events.Po
if n := len(post.Images); n > 0 {
ev.Images = make([]events.Image, 0, n)
for _, img := range post.Images {
if img.Kind == store.MediaKindVideo {
continue
}
ev.Images = append(ev.Images, events.Image{
URL: img.PublicURL,
Description: img.Description,
Kind: img.Kind,
})
}
}