11
11
namespace phpbb \webpushnotifications \controller ;
12
12
13
13
use phpbb \config \config ;
14
- use phpbb \exception \http_exception ;
15
- use phpbb \language \language ;
16
14
use phpbb \path_helper ;
17
15
use phpbb \user ;
18
16
use phpbb \webpushnotifications \ext ;
19
17
use Symfony \Component \HttpFoundation \JsonResponse ;
20
- use Symfony \Component \HttpFoundation \Response ;
21
18
22
19
class manifest
23
20
{
24
21
/** @var config */
25
22
protected $ config ;
26
23
27
- /** @var language */
28
- protected $ language ;
29
-
30
24
/** @var path_helper */
31
25
protected $ path_helper ;
32
26
@@ -38,14 +32,12 @@ class manifest
38
32
*
39
33
* @param config $config
40
34
* @param path_helper $path_helper
41
- * @param language $language
42
35
* @param user $user
43
36
*/
44
- public function __construct (config $ config , language $ language , path_helper $ path_helper , user $ user )
37
+ public function __construct (config $ config , path_helper $ path_helper , user $ user )
45
38
{
46
39
$ this ->config = $ config ;
47
40
$ this ->path_helper = $ path_helper ;
48
- $ this ->language = $ language ;
49
41
$ this ->user = $ user ;
50
42
}
51
43
@@ -56,11 +48,6 @@ public function __construct(config $config, language $language, path_helper $pat
56
48
*/
57
49
public function handle (): JsonResponse
58
50
{
59
- if ($ this ->user ->data ['is_bot ' ])
60
- {
61
- throw new http_exception (Response::HTTP_FORBIDDEN , 'NO_AUTH_OPERATION ' );
62
- }
63
-
64
51
$ board_path = $ this ->config ['force_server_vars ' ] ? $ this ->config ['script_path ' ] : $ this ->path_helper ->get_web_root_path ();
65
52
$ board_url = generate_board_url ();
66
53
@@ -73,7 +60,6 @@ public function handle(): JsonResponse
73
60
'short_name ' => $ pwa_short_name ?: utf8_substr ($ sitename , 0 , 12 ),
74
61
'display ' => 'standalone ' ,
75
62
'orientation ' => 'portrait ' ,
76
- 'dir ' => $ this ->language ->lang ('DIRECTION ' ),
77
63
'start_url ' => $ board_path ,
78
64
'scope ' => $ board_path ,
79
65
];
@@ -94,6 +80,17 @@ public function handle(): JsonResponse
94
80
];
95
81
}
96
82
97
- return new JsonResponse ($ manifest );
83
+ $ response = new JsonResponse ($ manifest );
84
+ $ response ->setPublic ();
85
+ $ response ->setMaxAge (3600 );
86
+ $ 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
+
94
+ return $ response ;
98
95
}
99
96
}
0 commit comments