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:
+14
-4
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"plumber/internal/events"
|
||||
"plumber/internal/store"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,14 @@ func (s *Server) handleCreatePost(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
defer cleanup()
|
||||
var media []events.Media
|
||||
held := false
|
||||
defer func() {
|
||||
if !held {
|
||||
closeHeldMedia(media)
|
||||
cleanup()
|
||||
}
|
||||
}()
|
||||
if !s.requireCSRF(w, r) {
|
||||
return
|
||||
}
|
||||
@@ -75,7 +83,7 @@ func (s *Server) handleCreatePost(w http.ResponseWriter, r *http.Request) {
|
||||
root = threadRoot
|
||||
}
|
||||
|
||||
images, newKeys, err := s.postImagesFromForm(r.Context(), r, post.ID, nil)
|
||||
images, newKeys, media, err := s.postImagesFromForm(r.Context(), r, post.ID, nil)
|
||||
if err != nil {
|
||||
writePostImageRequestError(w, err)
|
||||
return
|
||||
@@ -93,7 +101,8 @@ func (s *Server) handleCreatePost(w http.ResponseWriter, r *http.Request) {
|
||||
if root == nil {
|
||||
root = post
|
||||
}
|
||||
s.publishPostCreated(post, root, user)
|
||||
s.publishPostCreated(post, root, user, media, cleanup)
|
||||
held = true
|
||||
http.Redirect(
|
||||
w,
|
||||
r,
|
||||
@@ -139,11 +148,12 @@ func (s *Server) handleEditPost(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
previousImages := append([]store.PostImage(nil), post.Images...)
|
||||
images, newKeys, err := s.postImagesFromForm(r.Context(), r, post.ID, previousImages)
|
||||
images, newKeys, media, err := s.postImagesFromForm(r.Context(), r, post.ID, previousImages)
|
||||
if err != nil {
|
||||
writePostImageRequestError(w, err)
|
||||
return
|
||||
}
|
||||
closeHeldMedia(media)
|
||||
post.Body = truncateRunes(body, 12000)
|
||||
post.Images = images
|
||||
if err := s.store.UpdatePost(r.Context(), post); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user