From 41b42407cdbbd2ba836230824c3bb119bc698192 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Tue, 17 Aug 2021 21:46:43 +0100 Subject: [PATCH] [Posting] Store uploaded filenames as titles --- components/Posting/Posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index 8c4ba36de1..9478dee214 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -120,7 +120,7 @@ END; foreach ($attachments as $f) { // where $f is a Symfony\Component\HttpFoundation\File\UploadedFile $filesize = $f->getSize(); Event::handle('EnforceQuota', [$actor_id, $filesize]); - $processed_attachments[] = GSFile::sanitizeAndStoreFileAsAttachment($f); + $processed_attachments[] = [GSFile::sanitizeAndStoreFileAsAttachment($f), $f->getClientOriginalName()]; } DB::persist($note); @@ -128,11 +128,11 @@ END; // Need file and note ids for the next step DB::flush(); if ($processed_attachments != []) { - foreach ($processed_attachments as $a) { + foreach ($processed_attachments as [$a, $fname]) { if (is_null(DB::findBy('gsactor_to_attachment', ['attachment_id' => $a->getId(), 'gsactor_id' => $actor_id]))) { DB::persist(GSActorToAttachment::create(['attachment_id' => $a->getId(), 'gsactor_id' => $actor_id])); } - DB::persist(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId()])); + DB::persist(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId(), 'title' => $fname])); } DB::flush(); }