diff options
| author | winter | 2024-12-17 21:04:20 +0000 |
|---|---|---|
| committer | winter | 2024-12-17 21:04:20 +0000 |
| commit | c58caced838a9a7954e7fefa60c01567bb6bc107 (patch) | |
| tree | c68d6bb8f7c8b9636485e3f52f9a7b856316e0de /routes | |
| parent | 10793d22df72f12f2f14c730c09b5018b5b6e63a (diff) | |
winter REPORTEDLY forgot to implement subscribe routes
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/subscribe.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/routes/subscribe.php b/routes/subscribe.php index c18d484..91a611f 100644 --- a/routes/subscribe.php +++ b/routes/subscribe.php @@ -1,11 +1,23 @@ <?php +use Digitigrade\HttpResponseStatus\Unauthorized; +use Digitigrade\Model\Instance; use Digitigrade\Router; Router::getInstance()->mount('/subscribe', function (array $args) { - + $instance = Instance::findByRequestHeaders(); + if ($instance == null) { + throw new Unauthorized(); + } + $instance->auth->outboundPushEnabled = true; + http_response_code(204); // "No Content" }); Router::getInstance()->mount('/unsubscribe', function (array $args) { - + $instance = Instance::findByRequestHeaders(); + if ($instance == null) { + throw new Unauthorized(); + } + $instance->auth->outboundPushEnabled = false; + http_response_code(204); // "No Content" });
\ No newline at end of file |
