diff --git a/plugins/RepeatNote/Controller/Repeat.php b/plugins/RepeatNote/Controller/Repeat.php index 43e8b58901..2eac64a650 100644 --- a/plugins/RepeatNote/Controller/Repeat.php +++ b/plugins/RepeatNote/Controller/Repeat.php @@ -50,12 +50,12 @@ class Repeat extends Controller * @throws RedirectException * @throws ServerException */ - public function repeatAddNote(Request $request, int $id): bool|array + public function repeatAddNote(Request $request, int $note_id): bool|array { $user = Common::ensureLoggedIn(); $actor_id = $user->getId(); - $note = Note::getByPK(['id' => $id]); + $note = Note::getByPK(['id' => $note_id]); $form_add_to_repeat = Form::create([ ['add_repeat', SubmitType::class, @@ -103,7 +103,7 @@ class Repeat extends Controller * @throws RedirectException * @throws ServerException */ - public function repeatRemoveNote(Request $request, int $id): array + public function repeatRemoveNote(Request $request, int $note_id): array { $user = Common::ensureLoggedIn(); @@ -122,7 +122,7 @@ class Repeat extends Controller $form_remove_repeat->handleRequest($request); if ($form_remove_repeat->isSubmitted()) { - if (!\is_null(\Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $id, actor_id: $actor_id))) { + if (!\is_null(\Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $note_id, actor_id: $actor_id))) { DB::flush(); } else { throw new ClientException(_m('Note wasn\'t repeated!')); @@ -146,7 +146,7 @@ class Repeat extends Controller return [ '_template' => 'repeat/remove_from_repeats.html.twig', - 'note' => Note::getById($id), + 'note' => Note::getById($note_id), 'remove_repeat' => $form_remove_repeat->createView(), ]; } diff --git a/plugins/RepeatNote/RepeatNote.php b/plugins/RepeatNote/RepeatNote.php index 436581bfb0..b36363a4cb 100644 --- a/plugins/RepeatNote/RepeatNote.php +++ b/plugins/RepeatNote/RepeatNote.php @@ -60,6 +60,10 @@ class RepeatNote extends NoteHandlerPlugin ], order_by: ['created' => 'DESC'])[0]; } + // If it's a repeat, the reply_to should be to the original, conversation ought to be the same + $og_id = $note->getId(); + $extra_args['reply_to'] = $og_id; + // Create a new note with the same content as the original $repeat = Posting::storeLocalNote( actor: Actor::getById($actor_id), @@ -67,11 +71,11 @@ class RepeatNote extends NoteHandlerPlugin content_type: $note->getContentType(), language: \is_null($lang_id = $note->getLanguageId()) ? null : Language::getById($lang_id)->getLocale(), processed_attachments: $note->getAttachmentsWithTitle(), + process_note_content_extra_args: $extra_args, ); // Find the id of the note we just created $repeat_id = $repeat?->getId(); - $og_id = $note->getId(); // Add it to note_repeat table if (!\is_null($repeat_id)) { @@ -182,7 +186,7 @@ class RepeatNote extends NoteHandlerPlugin } // Generating URL for repeat action route - $args = ['id' => $is_repeat === 0 ? $note->getId() : $note_repeat[0]->getRepeatOf()]; + $args = ['note_id' => $is_repeat === 0 ? $note->getId() : $note_repeat[0]->getRepeatOf()]; $type = Router::ABSOLUTE_PATH; $repeat_action_url = $is_repeat ? Router::url('repeat_remove', $args, $type) @@ -199,7 +203,7 @@ class RepeatNote extends NoteHandlerPlugin 'url' => $repeat_action_url, 'title' => $is_repeat ? 'Remove this repeat' : 'Repeat this note!', 'classes' => "button-container repeat-button-container {$extra_classes}", - 'id' => 'repeat-button-container-' . $note->getId(), + 'note_id' => 'repeat-button-container-' . $note->getId(), ]; $actions[] = $repeat_action; @@ -265,8 +269,8 @@ class RepeatNote extends NoteHandlerPlugin public function onAddRoute(RouteLoader $r): bool { // Add/remove note to/from repeats - $r->connect(id: 'repeat_add', uri_path: '/object/note/{id<\d+>}/repeat', target: [Controller\Repeat::class, 'repeatAddNote']); - $r->connect(id: 'repeat_remove', uri_path: '/object/note/{id<\d+>}/unrepeat', target: [Controller\Repeat::class, 'repeatRemoveNote']); + $r->connect(id: 'repeat_add', uri_path: '/object/note/{note_id<\d+>}/repeat', target: [Controller\Repeat::class, 'repeatAddNote']); + $r->connect(id: 'repeat_remove', uri_path: '/object/note/{note_id<\d+>}/unrepeat', target: [Controller\Repeat::class, 'repeatRemoveNote']); return Event::next; }