Skip to content

Commit 91b664f

Browse files
author
jessevz
committed
fixed copilot suggestions
1 parent 2a9890c commit 91b664f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/inc/apiv2/helper/getTaskProgressImage.routes.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getParamsSwagger(): array {
5050
"type" => "integer",
5151
"format" => "int32"
5252
],
53-
"required" => true,
53+
"required" => false,
5454
"example" => 1,
5555
"description" => "The ID of the supertask where you want to create the progress image of."
5656
],
@@ -61,7 +61,7 @@ public function getParamsSwagger(): array {
6161
"type" => "integer",
6262
"format" => "int32"
6363
],
64-
"required" => true,
64+
"required" => false,
6565
"example" => 1,
6666
"description" => "The ID of the task where you want to create the progress image of."
6767
]
@@ -86,15 +86,15 @@ public function handleGet(Request $request, Response $response): Response {
8686
if ($task_id) {
8787
$task = Factory::getTaskFactory()->get($task_id);
8888
if ($task == null) {
89-
throw new HttpNotFoundException($request, "Invalid file");
89+
throw new HttpNotFoundException($request, "Invalid task");
9090
}
9191
$taskWrapper = Factory::getTaskWrapperFactory()->get($task->getTaskWrapperId());
9292
if ($taskWrapper == null) {
9393
throw new HttpError("Inconsistency on task!");
9494
}
9595
}
9696
else if ($supertask_id) {
97-
$taskWrapper = Factory::getTaskWrapperFactory()->get($_GET['supertask']);
97+
$taskWrapper = Factory::getTaskWrapperFactory()->get($supertask_id);
9898
if ($taskWrapper == null) {
9999
throw new HttpError("Invalid task wrapper!");
100100
}
@@ -201,7 +201,11 @@ public function handleGet(Request $request, Response $response): Response {
201201
}
202202

203203
//send image data to output
204+
ob_start($image);
204205
imagepng($image);
206+
$imageData = ob_get_clean();
207+
imagedestroy($image);
208+
$response->getBody()->write($imageData);
205209
return $response->withStatus(200)
206210
->withHeader("Content-Type", "image/png")
207211
->withHeader("Cache-Control", "no-cache");

0 commit comments

Comments
 (0)