aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/note_fragment.php
diff options
context:
space:
mode:
authorwinter2025-01-16 18:33:18 +0000
committerwinter2025-01-16 18:33:18 +0000
commit8de5608976dc8a73a400267601acb4c8e127de5a (patch)
treea907dd4c4e55e331979cd9ce14852592af2654a0 /routes/note_fragment.php
parente3a0248c3b1762abf5138fbd1b8228601006d44d (diff)
note privacy and summary stuff
Diffstat (limited to 'routes/note_fragment.php')
-rw-r--r--routes/note_fragment.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/routes/note_fragment.php b/routes/note_fragment.php
index 4d8c1a6..84f68c6 100644
--- a/routes/note_fragment.php
+++ b/routes/note_fragment.php
@@ -4,6 +4,7 @@ use Digitigrade\HttpResponseStatus\BadRequest;
use Digitigrade\Model\Interaction;
use Digitigrade\Model\InteractionKind;
use Digitigrade\Model\Note;
+use Digitigrade\Model\NotePrivacyScope;
use Digitigrade\Model\UserAccount;
use Digitigrade\Router;
@@ -42,8 +43,16 @@ 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');
+ if (isset($_POST['content']) && strlen(trim($_POST['content'])) > 0) {
+ $summary = trim($_POST['summary'] ?? '');
+ $summary = $summary == '' ? null : $summary;
+ $reply = Note::create(
+ $author->actor,
+ trim($_POST['content']),
+ 'unk',
+ $summary,
+ $note->privacy->scope
+ );
$reply->inReplyTo = $note;
$reply->threadApex = $note->threadApex ?? $note;
$reply->save();
@@ -56,9 +65,17 @@ Router::getInstance()->mount('/fragment/note/:id/reply', function (array $args)
Router::getInstance()->mount('/fragment/note', function (array $args) {
// posting a new note
$author = UserAccount::requireByCurrentSession();
- if (isset($_POST['content'])) {
- // TODO: summary field, post language, privacy, etc
- $note = Note::create($author->actor, $_POST['content'], 'unk');
+ if (isset($_POST['content']) && strlen(trim($_POST['content'])) > 0) {
+ // TODO: post language, other privacy options, etc
+ $summary = trim($_POST['summary'] ?? '');
+ $summary = $summary == '' ? null : $summary;
+ $note = Note::create(
+ $author->actor,
+ trim($_POST['content']),
+ 'unk',
+ $summary,
+ NotePrivacyScope::from($_POST['scope'])
+ );
$note->publish();
$note->processTimelineAdditions();
}