mirror of
https://github.com/v2board/v2board.git
synced 2025-01-25 15:39:10 +08:00
update: fix node etag
This commit is contained in:
parent
63566fbd2c
commit
0c935c5e3e
@ -26,7 +26,7 @@ class ServerController extends Controller
|
|||||||
$serverService = new ServerService();
|
$serverService = new ServerService();
|
||||||
$servers = $serverService->getAvailableServers($user);
|
$servers = $serverService->getAvailableServers($user);
|
||||||
}
|
}
|
||||||
$eTag = sha1(json_encode(array_column($servers, 'is_online', 'updated_at')));
|
$eTag = sha1(json_encode(array_column($servers, 'cache_key')));
|
||||||
if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
|
if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
|
||||||
abort(304);
|
abort(304);
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ class ServerService
|
|||||||
$servers = array_map(function ($server) {
|
$servers = array_map(function ($server) {
|
||||||
$server['port'] = (int)$server['port'];
|
$server['port'] = (int)$server['port'];
|
||||||
$server['is_online'] = (time() - 300 > $server['last_check_at']) ? 0 : 1;
|
$server['is_online'] = (time() - 300 > $server['last_check_at']) ? 0 : 1;
|
||||||
|
$server['cache_key'] = "{$server['type']}-{$server['id']}-{$server['updated_at']}-{$server['is_online']}";
|
||||||
return $server;
|
return $server;
|
||||||
}, $servers);
|
}, $servers);
|
||||||
return $servers;
|
return $servers;
|
||||||
|
Loading…
Reference in New Issue
Block a user