69 lines
2.6 KiB
PHP
69 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace routes;
|
|
|
|
use classes\limble;
|
|
use classes\response;
|
|
use classes\router;
|
|
use classes\slack;
|
|
use limble\helpers\limble_webhook_payload_task;
|
|
use traits\route_t;
|
|
|
|
class moduleLimbleRoute
|
|
{
|
|
use route_t;
|
|
|
|
public function run(): void
|
|
{
|
|
global /** @var response $response */
|
|
/** @var router $router */
|
|
$router, $response;
|
|
$this->post('/modules/limble/webhook/task', function () {
|
|
global $response;
|
|
$slack = new slack();
|
|
$slack->send_message('Limble Webhook Task Triggered', 'Limble Webhook');
|
|
//TODO: Add authentication of some sort here
|
|
//self::requirePermission('modules_limble_webhooks_task');
|
|
// Check if the module is enabled
|
|
$limble = new limble();
|
|
$limble->requireModuleEnabled();
|
|
$limble->requireWebhooksEnabled();
|
|
$payload = json_decode(file_get_contents('php://input'), true);
|
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
$response->error('Invalid JSON payload', 400);
|
|
}
|
|
$slack->send_message('TaskId: ' . ($payload['taskID'] ?? 'Not provided'), 'Limble Webhook Task ID');
|
|
$slack->send_message('Payload: ' . json_encode($payload), 'Limble Webhook Task Payload');
|
|
$task = new limble_webhook_payload_task($payload);
|
|
//$task = new $limble->helpers->limble_webhook_payload_task($payload);
|
|
$slack->send_message('Limble Webhook Task Received: ' . $task->taskID, 'Limble Webhook Task');
|
|
$slack->send_message('Task Name: ' . $task->taskObject->name, 'Limble Webhook Task Name');
|
|
// $slack->send_message('Task ID: ' . $payload['task_id'], 'Limble Webhook Task ID');
|
|
|
|
// Response
|
|
$response->success('Debug', 200);
|
|
},
|
|
[
|
|
'modules_limble_webhooks_task' => 'Send Limble Webhook Task (POST)',
|
|
]
|
|
);
|
|
|
|
$this->get('/modules/limble/tasks', function () {
|
|
global $response;
|
|
$slack = new slack();
|
|
$slack->send_message('Limble Tasks Endpoint Triggered', 'Limble Tasks');
|
|
//self::requirePermission('modules_limble_tasks');
|
|
// Check if the module is enabled
|
|
$limble = new limble();
|
|
$limble->requireModuleEnabled();
|
|
// Get the tasks
|
|
$tasks = $limble->getTasks()->formatTasks($limble->listTasks());
|
|
// Response
|
|
$response->success($tasks, 200);
|
|
},
|
|
[
|
|
'modules_limble_tasks' => 'Get Limble Tasks (GET)',
|
|
]
|
|
);
|
|
}
|
|
} |