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:
+21
-5
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user