[NOTE][Posting] Revert regressions introduced with c90efe2c52
Entity Note: It doesn't make sense to handle attachments on Note::create. Attachments exist out of Notes, they are a thing on their own. Furthermore, they aren't always handled the same, they most definitely aren't always uploaded files. FileQuota: It doesn't make sense to check if a file is greater than max allowed upload size here. The plugin ensures a user is inside his allowed quota, it's ignorant to anything else. Whether a file respect max upload is a core thing that must be handled directly in the Posting component. TODO: The configuration regarding user and monthly quota must become FileQuotaPlugin settings and be removed from core. c90efe2c52 - [UI] Add mechanism for rendering note contents in different formats. Implement plaintext rendering. Use rendered field for note content, rather than the content itself
This commit is contained in:
@@ -25,7 +25,6 @@ use App\Core\Cache;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Entity;
|
||||
use App\Core\Event;
|
||||
use App\Core\GSFile;
|
||||
use App\Core\VisibilityScope;
|
||||
use DateTimeInterface;
|
||||
|
||||
@@ -299,40 +298,6 @@ class Note extends Entity
|
||||
['note_id' => $this->id, 'actor_id' => $a->getId()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of NoteToLink or fill in the
|
||||
* properties of $obj with the associative array $args. Does
|
||||
* persist the result
|
||||
*/
|
||||
public static function create(array $args, mixed $obj = null): self
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\File\UploadedFile[] $attachments */
|
||||
$attachments = $args['attachments'];
|
||||
unset($args['attachments']);
|
||||
|
||||
$note = parent::create($args, new self());
|
||||
|
||||
$processed_attachments = [];
|
||||
foreach ($attachments as $f) {
|
||||
Event::handle('EnforceUserFileQuota', [$f->getSize(), $args['actor_id']]);
|
||||
$processed_attachments[] = [GSFile::sanitizeAndStoreFileAsAttachment($f), $f->getClientOriginalName()];
|
||||
}
|
||||
|
||||
// Need file and note ids for the next step
|
||||
DB::persist($note);
|
||||
|
||||
if ($processed_attachments != []) {
|
||||
foreach ($processed_attachments as [$a, $fname]) {
|
||||
if (DB::count('actor_to_attachment', $args = ['attachment_id' => $a->getId(), 'actor_id' => $args['actor_id']]) === 0) {
|
||||
DB::persist(ActorToAttachment::create($args));
|
||||
}
|
||||
DB::persist(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId(), 'title' => $fname]));
|
||||
}
|
||||
}
|
||||
|
||||
return $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Actor[]
|
||||
*/
|
||||
|
Reference in New Issue
Block a user