[AUTOGENERATED] Update auto generated code

This commit is contained in:
2021-12-26 15:12:06 +00:00
committed by Diogo Peralta Cordeiro
parent 68076d73dd
commit c79b1e4c94
61 changed files with 426 additions and 434 deletions

View File

@@ -24,21 +24,20 @@ declare(strict_types = 1);
namespace Component\Posting;
use App\Core\DB\DB;
use App\Core\Entity;
use App\Core\Event;
use App\Core\Form;
use App\Core\GSFile;
use App\Core\VisibilityScope;
use App\Util\Exception\BugFoundException;
use function App\Core\I18n\_m;
use App\Core\Modules\Component;
use App\Core\Router\Router;
use App\Core\Security;
use App\Core\VisibilityScope;
use App\Entity\Activity;
use App\Entity\Actor;
use App\Entity\GroupInbox;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exception\BugFoundException;
use App\Util\Exception\ClientException;
use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\RedirectException;
@@ -58,8 +57,6 @@ use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\Length;
use function count;
use function is_null;
class Posting extends Component
{
@@ -73,7 +70,7 @@ class Posting extends Component
*/
public function onAppendRightPostingBlock(Request $request, array &$res): bool
{
if (is_null($user = Common::user())) {
if (\is_null($user = Common::user())) {
return Event::next;
}
@@ -105,15 +102,15 @@ class Posting extends Component
// TODO: if in group page, add GROUP visibility to the choices.
$form_params[] = ['visibility', ChoiceType::class, ['label' => _m('Visibility:'), 'multiple' => false, 'expanded' => false, 'data' => 'public', 'choices' => [
_m('Public') => VisibilityScope::PUBLIC,
_m('Local') => VisibilityScope::LOCAL,
_m('Addressee') => VisibilityScope::ADDRESSEE
_m('Public') => VisibilityScope::PUBLIC,
_m('Local') => VisibilityScope::LOCAL,
_m('Addressee') => VisibilityScope::ADDRESSEE,
]]];
$form_params[] = ['content', TextareaType::class, ['label' => _m('Content:'), 'data' => $initial_content, 'attr' => ['placeholder' => _m($placeholder)], 'constraints' => [new Length(['max' => Common::config('site', 'text_limit')])]]];
$form_params[] = ['attachments', FileType::class, ['label' => _m('Attachments:'), 'multiple' => true, 'required' => false, 'invalid_message' => _m('Attachment not valid.')]];
$form_params[] = FormFields::language($actor, $context_actor, label: _m('Note language'), help: _m('The selected language will be federated and added as a lang attribute, preferred language can be set up in settings'));
if (count($available_content_types) > 1) {
if (\count($available_content_types) > 1) {
$form_params[] = ['content_type', ChoiceType::class,
[
'label' => _m('Text format:'), 'multiple' => false, 'expanded' => false,
@@ -174,32 +171,25 @@ class Posting extends Component
* $actor_id, possibly as a reply to note $reply_to and with flag
* $is_local. Sanitizes $content and $attachments
*
* @param Actor $actor
* @param string|null $content
* @param string $content_type
* @param string|null $language
* @param int|null $scope
* @param string|null $target
* @param array $attachments Array of UploadedFile to be stored as GSFiles associated to this note
* @param array $processed_attachments Array of [Attachment, Attachment's name] to be associated to this $actor and Note
* @param array $attachments Array of UploadedFile to be stored as GSFiles associated to this note
* @param array $processed_attachments Array of [Attachment, Attachment's name] to be associated to this $actor and Note
* @param array $process_note_content_extra_args Extra arguments for the event ProcessNoteContent
*
* @return Note
* @throws BugFoundException
* @throws ClientException
* @throws DuplicateFoundException
* @throws ServerException
* @throws BugFoundException
*/
public static function storeLocalNote(
Actor $actor,
Actor $actor,
?string $content,
string $content_type,
string $content_type,
?string $language = null,
?int $scope = null,
?int $scope = null,
?string $target = null,
array $attachments = [],
array $processed_attachments = [],
array $process_note_content_extra_args = [],
array $attachments = [],
array $processed_attachments = [],
array $process_note_content_extra_args = [],
): Note {
$scope ??= VisibilityScope::PUBLIC; // TODO: If site is private, default to LOCAL
$rendered = null;
@@ -213,9 +203,9 @@ class Posting extends Component
'content' => $content,
'content_type' => $content_type,
'rendered' => $rendered,
'language_id' => !is_null($language) ? Language::getByLocale($language)->getId() : null,
'language_id' => !\is_null($language) ? Language::getByLocale($language)->getId() : null,
'is_local' => true,
'scope' => $scope,
'scope' => $scope,
]);
/** @var UploadedFile[] $attachments */
@@ -261,7 +251,7 @@ class Posting extends Component
]);
DB::persist($activity);
if (!is_null($target)) {
if (!\is_null($target)) {
switch ($target[0]) {
case '!':
$mentions[] = [
@@ -277,7 +267,7 @@ class Posting extends Component
$mentioned = [];
foreach (F\unique(F\flat_map($mentions, fn (array $m) => $m['mentioned'] ?? []), fn (Actor $a) => $a->getId()) as $m) {
if (!is_null($m)) {
if (!\is_null($m)) {
$mentioned[] = $m->getId();
if ($m->isGroup()) {