aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/actor.php19
-rw-r--r--routes/actor_profile_fragment.php14
-rw-r--r--routes/note_fragment.php5
-rw-r--r--routes/preferences.php1
4 files changed, 35 insertions, 4 deletions
diff --git a/routes/actor.php b/routes/actor.php
index d0bb066..a459640 100644
--- a/routes/actor.php
+++ b/routes/actor.php
@@ -1,5 +1,6 @@
<?php
+use Digitigrade\HttpResponseStatus\Forbidden;
use Digitigrade\HttpResponseStatus\NotFound;
use Digitigrade\HttpResponseStatus\PolicyRejected;
use Digitigrade\HttpResponseStatus\TemporaryRedirect;
@@ -9,6 +10,7 @@ use Digitigrade\Model\FollowRelationStatus;
use Digitigrade\Model\Instance;
use Digitigrade\Model\Note;
use Digitigrade\Model\NotePrivacyScope;
+use Digitigrade\PokeVerb;
use Digitigrade\PolicyManager;
use Digitigrade\Router;
@@ -147,4 +149,21 @@ Router::getInstance()->mount('/actor/:id/unblock', function (array $args) {
throw new Unauthorized('please authenticate yourself on behalf of the initiating actor');
}
$initiator->unblock($target);
+});
+
+Router::getInstance()->mount('/actor/:id/poke', function (array $args) {
+ $target = Actor::find($args['id']);
+ if ($target == null || !$target->isLocal || $target->deleted) {
+ throw new NotFound();
+ }
+ if (!$target->isPokeable()) {
+ throw new Forbidden('you may not poke this user!');
+ }
+ $initiator = Actor::findByRequestHeaders();
+ if ($initiator == null) {
+ throw new Unauthorized('please authenticate yourself on behalf of the initiating actor');
+ }
+ $body = file_get_contents('php://input');
+ $obj = json_decode($body);
+ $initiator->poke($target, PokeVerb::tryFrom($obj?->verb ?? '') ?? PokeVerb::POKE, $obj?->urgent ?? false);
}); \ No newline at end of file
diff --git a/routes/actor_profile_fragment.php b/routes/actor_profile_fragment.php
index d189f87..65f7a49 100644
--- a/routes/actor_profile_fragment.php
+++ b/routes/actor_profile_fragment.php
@@ -1,9 +1,11 @@
<?php
+use Digitigrade\HttpResponseStatus\Forbidden;
use Digitigrade\HttpResponseStatus\PolicyRejected;
use Digitigrade\Model\Actor;
use Digitigrade\Model\StorageObject;
use Digitigrade\Model\UserAccount;
+use Digitigrade\PokeVerb;
use Digitigrade\PolicyManager;
use Digitigrade\Router;
use Digitigrade\StorageProvider\FilesystemStorage;
@@ -62,6 +64,18 @@ Router::getInstance()->mount('/fragment/actor/:id/blockButton', function (array
render_template('actor/profile_block_button', ['user' => $user, 'actor' => $actor]);
});
+Router::getInstance()->mount('/fragment/actor/:id/poke', function (array $args) {
+ $user = UserAccount::requireByCurrentSession();
+ $actor = Actor::find($args['id']);
+
+ if (!$actor->isPokeable()) {
+ throw new Forbidden("can't poke that user");
+ }
+ $user->actor->poke($actor, PokeVerb::from($_POST['verb']), isset($_POST['urgent']));
+
+ render_template('actor/profile_poke_form', ['actor' => $actor, 'poked' => true]);
+});
+
Router::getInstance()->mount('/fragment/profile', function (array $args) {
$user = UserAccount::requireByCurrentSession();
$actor = $user->actor;
diff --git a/routes/note_fragment.php b/routes/note_fragment.php
index 907260d..3d30a7a 100644
--- a/routes/note_fragment.php
+++ b/routes/note_fragment.php
@@ -142,10 +142,7 @@ Router::getInstance()->mount('/fragment/note/:id/edit', function (array $args) {
$note->publish();
if ($user->actor != $note->author) {
- Notification::fromNotifyable(
- new AdminEditedNoteNotif($user, $note),
- UserAccount::findByLinkedActor($note->author)
- )->send();
+ (new AdminEditedNoteNotif($user, $note))->processNotifications();
}
render_template('note/note', ['note' => $note]);
diff --git a/routes/preferences.php b/routes/preferences.php
index 99b8458..95e7228 100644
--- a/routes/preferences.php
+++ b/routes/preferences.php
@@ -16,6 +16,7 @@ Router::getInstance()->mount('/fragment/preferences', function (array $args) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// updating the preferences
$user->actor->requestToFollow = $_POST['requestToFollow'] == 'true';
+ $user->actor->setPokeable($_POST['pokeable'] == 'true');
$user->actor->save();
$settings->set('interface.smallUnreadIndicators', $_POST['smallIndicators']);
$settings->set('locale.timezone', $_POST['timezone']);