Skip to content

Commit

Permalink
Enhancements (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibranco authored Feb 17, 2024
1 parent ce0b7cd commit 5073b24
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 46 deletions.
26 changes: 12 additions & 14 deletions Src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Src/issues.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ function handleIssue($issue)
$issueResponse = requestGitHub($metadata["token"], $metadata["issuesUrl"]);
$issueUpdated = json_decode($issueResponse["body"]);

if ($issueUpdated->state != "open") {
return;
}

echo "Issue " . $issueUpdated->number . " - " . $issueUpdated->title . " is open\n";
echo "Issue " . $issueUpdated->number . " - " . trim($issueUpdated->title) . " is " . $issueUpdated->state . "\n";
}

function main()
Expand Down
23 changes: 1 addition & 22 deletions Src/lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,7 @@ function sendHealthCheck($token, $type = null)
return;
}

$headers = array();
$headers[] = "User-Agent: " . USER_AGENT;

$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => "https://hc-ping.com/" . $token . ($type == null ? "" : $type),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => $headers

)
);
curl_exec($curl);
curl_close($curl);
doRequest("https://hc-ping.com/" . $token . ($type == null ? "" : $type));
}

function toCamelCase($inputString)
Expand Down
4 changes: 2 additions & 2 deletions Src/lib/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function sendByLib($queueName, $payload)
$channel->close();
$connection->close();
} catch (Exception $e) {
file_put_contents("rabbitmq.error_log", "[" . date("Y-m-d H:i:s") . "] ERROR sending: " . $e->getMessage() . "\n", FILE_APPEND);
file_put_contents("rabbitmq.error_log", "[" . date("Y-m-d H:i:s e") . "] ERROR sending " . $queueName . ": " . $e->getMessage() . "\n", FILE_APPEND);
if (!is_dir("logs")) {
mkdir("logs");
}
Expand Down Expand Up @@ -79,6 +79,6 @@ function receiveByLib($queueName, $callback)
$channel->close();
$connection->close();
} catch (Exception $e) {
file_put_contents("rabbitmq.error_log", "[" . date("Y-m-d H:i:s") . "] ERROR receiving: " . $e->getMessage() . "\n", FILE_APPEND);
file_put_contents("rabbitmq.error_log", "[" . date("Y-m-d H:i:s e") . "] ERROR receiving " . $queueName . ": " . $e->getMessage() . "\n", FILE_APPEND);
}
}
8 changes: 5 additions & 3 deletions Src/lib/request.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php


function doRequest($url, $authorizationBearerToken, $data = null)
function doRequest($url, $authorizationBearerToken = null, $data = null)
{
$headers = array();
$headers[] = "User-Agent: " . USER_AGENT;
$headers[] = "Content-type: application/json";
$headers[] = "Authorization: Bearer " . $authorizationBearerToken;
if ($authorizationBearerToken !== null) {
$headers[] = "Content-type: application/json";
$headers[] = "Authorization: Bearer " . $authorizationBearerToken;
}

$fields = array(
CURLOPT_URL => $url,
Expand Down

0 comments on commit 5073b24

Please sign in to comment.