From d6f086a22a01cef5605a977d21813a6f05b3d77b Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Thu, 19 Jan 2023 15:11:05 +0100 Subject: [PATCH] Fix sending hashtags and mentions Signed-off-by: Louis Chemineau --- lib/Controller/LocalController.php | 6 +- src/components/Composer/Composer.vue | 350 +++++++++++++-------------- 2 files changed, 175 insertions(+), 181 deletions(-) diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index 5548f1f7..b75e237f 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -124,14 +124,10 @@ class LocalController extends Controller { * * @NoAdminRequired */ - public function postCreate(string $content = '', $to = null, string $type = null, ?string $replyTo = null, $attachments = null, ?string $hashtags = null): DataResponse { + public function postCreate(string $content = '', array $to = [], string $type = null, ?string $replyTo = null, $attachments = null, array $hashtags = []): DataResponse { $content = $content ?: ''; - $to = is_string($to) ? [$to] : $to; - $to = $to ?? []; $replyTo = $replyTo ?? ''; $type = $type ?? Stream::TYPE_PUBLIC; - $hashtags = $hashtags === '' ? [] : $hashtags; - $hashtags = $hashtags ?? []; $attachments = $attachments ?? []; try { diff --git a/src/components/Composer/Composer.vue b/src/components/Composer/Composer.vue index b5f8a9ac..45506dc7 100644 --- a/src/components/Composer/Composer.vue +++ b/src/components/Composer/Composer.vue @@ -477,14 +477,12 @@ export default { const formData = new FormData() formData.append('content', content) - formData.append('to', to) - formData.append('hashtags', hashtags) + to.forEach(to => formData.append('to[]', to)) + hashtags.forEach(hashtag => formData.append('hashtags[]', hashtag)) formData.append('type', this.type) - for (const preview of this.previewUrls) { - // TODO send the summary and other props too - formData.append('attachments[]', preview.result) - formData.append('attachmentDescriptions[]', preview.description) - } + this.previewUrls.forEach(preview => formData.append('attachments[]', preview.result)) + this.previewUrls.forEach(preview => formData.append('attachmentDescriptions[]', preview.description)) + if (this.replyTo) { formData.append('replyTo', this.replyTo.id) } @@ -557,122 +555,146 @@ export default { +