[PLUGIN][ActivityPub][Model][Note] Add name property as note title

This commit is contained in:
Diogo Peralta Cordeiro 2022-02-17 18:45:30 +00:00
parent 0a741903a1
commit 27635d8ec2
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,7 @@ use App\Core\ActorLocalRoles;
use App\Core\Controller;
use App\Core\Event;
use App\Core\Form;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\RedirectResponse;
use function App\Core\I18n\_m;
use App\Core\Router\Router;
@ -100,6 +101,7 @@ class Post extends Controller
}
$form_params[] = ['visibility', ChoiceType::class, ['label' => _m('Visibility:'), 'multiple' => false, 'expanded' => false, 'choices' => $visibility_options]];
$form_params[] = ['title', TextType::class, ['label' => _m('Title:'), 'constraints' => [new Length(['max' => 129])], 'required' => true]];
$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'));
@ -149,6 +151,7 @@ class Post extends Controller
reply_to: $data['reply_to_id'],
attachments: $data['attachments'],
process_note_content_extra_args: $extra_args,
title: $data['title'],
);
return new RedirectResponse($note->getConversationUrl());

View File

@ -229,6 +229,7 @@ class Posting extends Component
bool $flush_and_notify = true,
?string $rendered = null,
string $source = 'web',
?string $title = null,
): array {
[$activity, $note, $attention_ids] = self::storeLocalNote(
actor: $actor,
@ -246,6 +247,7 @@ class Posting extends Component
source: $source
);
$note->setType(NoteType::PAGE);
$note->setTitle($title);
if ($flush_and_notify) {
// Flush before notification

View File

@ -147,6 +147,7 @@ class Note extends Model
'created' => new DateTime($type_note->get('published') ?? 'now'),
'content' => $type_note->get('content') ?? null,
'rendered' => $type_note->has('content') ? HTML::sanitize($type_note->get('content')) : null,
'title' => $type_note->get('name') ?? null,
'content_type' => 'text/html',
'language_id' => $type_note->get('contentLang') ?? null,
'url' => $type_note->get('url') ?? $type_note->get('id'),
@ -336,6 +337,7 @@ class Note extends Model
'id' => $object->getUrl(),
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
'attributedTo' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
'name' => $object->getTitle(),
'content' => $object->getRendered(),
'mediaType' => 'text/html',
'source' => ['content' => $object->getContent(), 'mediaType' => $object->getContentType()],