mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 07:27:47 +00:00
feat(#2): add support for image_url_timeout
This commit is contained in:
parent
0c0a3026ce
commit
eee79fd11f
3 changed files with 52 additions and 3 deletions
|
|
@ -40,6 +40,7 @@ return [
|
||||||
'proxy_refresh_minutes' => env('TRMNL_PROXY_REFRESH_MINUTES', 15),
|
'proxy_refresh_minutes' => env('TRMNL_PROXY_REFRESH_MINUTES', 15),
|
||||||
'proxy_refresh_cron' => env('TRMNL_PROXY_REFRESH_CRON'),
|
'proxy_refresh_cron' => env('TRMNL_PROXY_REFRESH_CRON'),
|
||||||
'override_orig_icon' => env('TRMNL_OVERRIDE_ORIG_ICON', false),
|
'override_orig_icon' => env('TRMNL_OVERRIDE_ORIG_ICON', false),
|
||||||
|
'image_url_timeout' => env('TRMNL_IMAGE_URL_TIMEOUT', null),
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ Route::get('/display', function (Request $request) {
|
||||||
$filename = basename($image_path);
|
$filename = basename($image_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json([
|
$response = [
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'image_url' => url('storage/'.$image_path),
|
'image_url' => url('storage/'.$image_path),
|
||||||
'filename' => $filename,
|
'filename' => $filename,
|
||||||
|
|
@ -86,7 +86,13 @@ Route::get('/display', function (Request $request) {
|
||||||
'update_firmware' => $device->update_firmware,
|
'update_firmware' => $device->update_firmware,
|
||||||
'firmware_url' => $device->firmware_url,
|
'firmware_url' => $device->firmware_url,
|
||||||
'special_function' => 'sleep',
|
'special_function' => 'sleep',
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
if (config('services.trmnl.image_url_timeout')) {
|
||||||
|
$response['image_url_timeout'] = config('services.trmnl.image_url_timeout');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/setup', function (Request $request) {
|
Route::get('/setup', function (Request $request) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,48 @@ test('device can fetch display data with valid credentials', function () {
|
||||||
->last_firmware_version->toBe('1.0.0');
|
->last_firmware_version->toBe('1.0.0');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('display endpoint includes image_url_timeout when configured', function () {
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'mac_address' => '00:11:22:33:44:55',
|
||||||
|
'api_key' => 'test-api-key',
|
||||||
|
]);
|
||||||
|
|
||||||
|
config(['services.trmnl.image_url_timeout' => 300]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'id' => $device->mac_address,
|
||||||
|
'access-token' => $device->api_key,
|
||||||
|
'rssi' => -70,
|
||||||
|
'battery_voltage' => 3.8,
|
||||||
|
'fw-version' => '1.0.0',
|
||||||
|
])->get('/api/display');
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'image_url_timeout' => 300,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('display endpoint omits image_url_timeout when not configured', function () {
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'mac_address' => '00:11:22:33:44:55',
|
||||||
|
'api_key' => 'test-api-key',
|
||||||
|
]);
|
||||||
|
|
||||||
|
config(['services.trmnl.image_url_timeout' => null]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'id' => $device->mac_address,
|
||||||
|
'access-token' => $device->api_key,
|
||||||
|
'rssi' => -70,
|
||||||
|
'battery_voltage' => 3.8,
|
||||||
|
'fw-version' => '1.0.0',
|
||||||
|
])->get('/api/display');
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJsonMissing(['image_url_timeout']);
|
||||||
|
});
|
||||||
|
|
||||||
test('new device is auto-assigned to user with auto-assign enabled', function () {
|
test('new device is auto-assigned to user with auto-assign enabled', function () {
|
||||||
$user = User::factory()->create(['assign_new_devices' => true]);
|
$user = User::factory()->create(['assign_new_devices' => true]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue