Skip to content

Commit 31ca05f

Browse files
authored
Merge pull request #1483 from KodeStar/2.x
Fix for some enhanced apps not working
2 parents 6b9f61b + cd95fc3 commit 31ca05f

File tree

5 files changed

+40
-34
lines changed

5 files changed

+40
-34
lines changed

app/Http/Controllers/ItemController.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,35 +429,44 @@ public function appload(Request $request): ?string
429429
return null;
430430
}
431431

432-
$output['config'] = null;
433-
$output['custom'] = null;
434-
435432
$app = Application::single($appid);
433+
434+
if (!$app) {
435+
return response()->json(['error' => 'Application not found.'], 404);
436+
}
437+
436438
$output = (array)$app;
437439

438440
$appdetails = Application::getApp($appid);
439441

442+
if (!$appdetails) {
443+
return response()->json(['error' => 'Application details not found.'], 404);
444+
}
445+
440446
if ((bool)$app->enhanced === true) {
441447
$item = $itemId ? Item::find($itemId) : Item::where('appid', $appid)->first();
442-
// if(!isset($app->config)) { // class based config
443-
$output['custom'] = className($appdetails->name) . '.config';
444-
$output['appvalue'] = $item->description;
445-
// }
448+
449+
if ($item) {
450+
$output['custom'] = className($appdetails->name) . '.config';
451+
$output['appvalue'] = $item->description;
452+
} else {
453+
// Ensure the app is installed if not found
454+
$output['custom'] = className($appdetails->name) . '.config';
455+
$output['appvalue'] = null;
456+
}
446457
}
447458

448459
$output['colour'] = ($app->tile_background == 'light') ? '#fafbfc' : '#161b1f';
449460

450461
if (strpos($app->icon, '://') !== false) {
451462
$output['iconview'] = $app->icon;
452463
} elseif (strpos($app->icon, 'icons/') !== false) {
453-
// Private apps have the icon locally
454464
$output['iconview'] = URL::to('/') . '/storage/' . $app->icon;
455465
$output['icon'] = str_replace('icons/', '', $output['icon']);
456466
} else {
457467
$output['iconview'] = config('app.appsource') . 'icons/' . $app->icon;
458468
}
459469

460-
461470
return json_encode($output);
462471
}
463472

app/Http/Controllers/SearchController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@ public function index(Request $request)
2121
// Sanitize the query to prevent XSS
2222
$query = htmlspecialchars($query, ENT_QUOTES, 'UTF-8');
2323

24-
// Validate the presence and non-emptiness of the query parameter
25-
if (!$query || trim($query) === '') {
26-
abort(400, 'Missing or empty query parameter');
27-
}
28-
2924
$provider = Search::providerDetails($requestprovider);
3025

3126
if (!$provider || !isset($provider->type)) {
3227
abort(404, 'Invalid provider');
3328
}
3429

30+
// If the query is empty, redirect to the provider's base URL
31+
if (!$query || trim($query) === '') {
32+
return redirect($provider->url);
33+
}
34+
3535
if ($provider->type == 'standard') {
3636
return redirect($provider->url.'?'.$provider->query.'='.urlencode($query));
3737
} elseif ($provider->type == 'external') {
3838
$class = new $provider->class;
3939
return $class->getResults($query, $provider);
4040
}
4141

42-
abort(404, 'Provider type not supported');}
42+
abort(404, 'Provider type not supported');
43+
}
4344
}

app/Services/CustomFormBuilder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ public function text($name, $value = null, $options = [])
2121
);
2222
}
2323

24+
public function hidden($name, $value = null, $options = [])
25+
{
26+
return new HtmlString(
27+
$this->html->input('hidden', $name, $value)->attributes($options)
28+
);
29+
}
30+
31+
public function checkbox($name, $value = null, $checked = false, $options = [])
32+
{
33+
return new HtmlString(
34+
$this->html->checkbox($name, $value, $checked)->attributes($options)
35+
);
36+
}
37+
2438
public function select($name, $list = [], $selected = null, $options = [])
2539
{
2640
return new HtmlString(

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
return [
77

8-
'version' => '2.7.3',
8+
'version' => '2.7.4',
99

1010
'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'),
1111

tests/Feature/SearchTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,4 @@ public function test_search_page_with_invalid_provider(): void
3232
$response->assertStatus(404); // Assert that the response status is 404
3333
}
3434

35-
public function test_search_page_without_query_parameter(): void
36-
{
37-
$provider = 'google'; // Example provider
38-
39-
$response = $this->get(route('search', ['provider' => $provider]));
40-
41-
$response->assertStatus(400); // Assert that the response status is 400 (Bad Request)
42-
}
43-
44-
public function test_search_page_with_empty_query(): void
45-
{
46-
$provider = 'google'; // Example provider
47-
$query = ''; // Empty search term
48-
49-
$response = $this->get(route('search', ['provider' => $provider, 'q' => $query]));
50-
51-
$response->assertStatus(400); // Assert that the response status is 400 (Bad Request)
52-
}
5335
}

0 commit comments

Comments
 (0)