🔄Sync hub 2.0
Some checks are pending
docker / docker_dev (push) Waiting to run

This commit is contained in:
jokob-sk
2024-09-14 10:37:30 +10:00
parent aefe470d31
commit d858f4f9d0
4 changed files with 11 additions and 10 deletions

View File

@@ -24,14 +24,14 @@ function checkAuthorization($method) {
// ----------------------------------------------
// Function to return JSON response
function jsonResponse($status, $data = [], $message = '') {
function jsonResponse($status, $data = '', $message = '') {
http_response_code($status);
header('Content-Type: application/json');
echo json_encode([
'node_name' => getSettingValue('SYNC_node_name'),
'status' => $status,
'message' => $message,
'data' => $data,
'data_base64' => $data,
'timestamp' => date('Y-m-d H:i:s')
]);
}
@@ -50,13 +50,13 @@ if ($method === 'GET') {
$data = file_get_contents($file_path);
// Prepare the data to return as a JSON response
$response_data = [
'data_base64' => base64_encode($data),
];
$response_data = base64_encode($data);
// Return JSON response
jsonResponse(200, $response_data, 'OK');
write_notification("[Plugin: SYNC] Data sent", "info");
}
// receiving data (this is a HUB)
else if ($method === 'POST') {