[Posting] Store uploaded filenames as titles

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-17 21:46:43 +01:00 committed by Hugo Sales
parent 036e9cb58e
commit 41b42407cd
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 3 additions and 3 deletions

View File

@ -120,7 +120,7 @@ END;
foreach ($attachments as $f) { // where $f is a Symfony\Component\HttpFoundation\File\UploadedFile foreach ($attachments as $f) { // where $f is a Symfony\Component\HttpFoundation\File\UploadedFile
$filesize = $f->getSize(); $filesize = $f->getSize();
Event::handle('EnforceQuota', [$actor_id, $filesize]); Event::handle('EnforceQuota', [$actor_id, $filesize]);
$processed_attachments[] = GSFile::sanitizeAndStoreFileAsAttachment($f); $processed_attachments[] = [GSFile::sanitizeAndStoreFileAsAttachment($f), $f->getClientOriginalName()];
} }
DB::persist($note); DB::persist($note);
@ -128,11 +128,11 @@ END;
// Need file and note ids for the next step // Need file and note ids for the next step
DB::flush(); DB::flush();
if ($processed_attachments != []) { 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]))) { 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(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(); DB::flush();
} }