[Posting] Re-add original file to attachment on upload, if it was previously removed

This commit is contained in:
2021-08-12 04:41:00 +01:00
parent 9781ddc8e0
commit 3019048585
3 changed files with 56 additions and 35 deletions

View File

@@ -129,7 +129,9 @@ END;
DB::flush();
if ($processed_attachments != []) {
foreach ($processed_attachments as $a) {
DB::persist(GSActorToAttachment::create(['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(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId()]));
}
DB::flush();