aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
authorwinter2025-01-13 20:37:34 +0000
committerwinter2025-01-13 20:37:34 +0000
commitf31d2abc237958bd9f33875f20198c4510389556 (patch)
tree57c0920666ca052d8850824ad47b326631764aa6 /routes
parentfb9efd9f4682f528b1832622d192b9b5544584a9 (diff)
implement replying to posts
Diffstat (limited to 'routes')
-rw-r--r--routes/note_fragment.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/routes/note_fragment.php b/routes/note_fragment.php
index 9170e2b..83e7655 100644
--- a/routes/note_fragment.php
+++ b/routes/note_fragment.php
@@ -32,6 +32,20 @@ Router::getInstance()->mount('/fragment/note/:id/:action', function (array $args
render_template('interaction_button', ['action' => $args['action'], 'active' => $active, 'note' => $note]);
});
+Router::getInstance()->mount('/fragment/note/:id/reply', function (array $args) {
+ // replying to a note
+ $author = UserAccount::requireByCurrentSession();
+ $note = Note::find($args['id']);
+ if (isset($_POST['content'])) {
+ $reply = Note::create($author->actor, $_POST['content'], 'unk');
+ $reply->inReplyTo = $note;
+ $reply->threadApex = $note->threadApex ?? $note;
+ $reply->save();
+ $reply->publish();
+ }
+ render_template('reply_form');
+});
+
Router::getInstance()->mount('/fragment/note', function (array $args) {
// posting a new note
$author = UserAccount::requireByCurrentSession();