Skip to content

Commit 6e2b466

Browse files
committed
Handle bots with care
1 parent d18224c commit 6e2b466

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

controller/manifest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
namespace phpbb\webpushnotifications\controller;
1212

1313
use phpbb\config\config;
14-
use phpbb\exception\http_exception;
1514
use phpbb\path_helper;
1615
use phpbb\user;
1716
use phpbb\webpushnotifications\ext;
1817
use Symfony\Component\HttpFoundation\JsonResponse;
19-
use Symfony\Component\HttpFoundation\Response;
2018

2119
class manifest
2220
{
@@ -50,11 +48,6 @@ public function __construct(config $config, path_helper $path_helper, user $user
5048
*/
5149
public function handle(): JsonResponse
5250
{
53-
if ($this->user->data['is_bot'])
54-
{
55-
throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION');
56-
}
57-
5851
$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
5952
$board_url = generate_board_url();
6053

@@ -91,6 +84,13 @@ public function handle(): JsonResponse
9184
$response->setPublic();
9285
$response->setMaxAge(3600);
9386
$response->headers->addCacheControlDirective('must-revalidate', true);
87+
88+
if (!empty($this->user->data['is_bot']))
89+
{
90+
// Let reverse proxies know we detected a bot.
91+
$response->headers->set('X-PHPBB-IS-BOT', 'yes');
92+
}
93+
9494
return $response;
9595
}
9696
}

0 commit comments

Comments
 (0)