Refactor input value handling and improve validation in ObjectsGlobal component

This commit is contained in:
Jeppe Bundgaard
2026-06-29 11:08:50 +02:00
parent 148b575767
commit 42f8ae0c47
13 changed files with 469 additions and 12 deletions
@@ -250,6 +250,60 @@ class moduleConfigRoute
]
);
/** Slack internal department goal progress config > GET */
$this->get('/slack/config/internal-department-goal-progress', function () {
global $response;
$this->requirePermission('slack_config');
$user = (new authentication())->get_user();
if (!$user) {
(new logs_o())->add('slack_config', 'global', 1, 0, 'SLACK_INTERNAL_DEPARTMENT_GOAL_PROGRESS_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
(new logs_o())->add('slack_config', 'global', 1, $user->id, 'SLACK_INTERNAL_DEPARTMENT_GOAL_PROGRESS_CONFIG', 'Successfully fetched Slack internal department goal progress config');
$response->success(
(new slack())->get_internal_department_goal_progress_config()
);
},
[
'slack_config' => 'Get Slack internal department goal progress config'
]
);
/** Slack internal department goal progress config > POST */
$this->post('/slack/config/internal-department-goal-progress', function () {
global $response;
$this->requirePermission('slack_config');
$user = (new authentication())->get_user();
if (!$user) {
(new logs_o())->add('slack_config', 'global', 1, 0, 'SLACK_INTERNAL_DEPARTMENT_GOAL_PROGRESS_CONFIG', 'No user found, or invalid session');
$response->error('Invalid session', 400);
}
$webhook_url = $response->getRequestParameter('internal_department_goal_progress_webhook_url')
?? $response->getRequestParameter('webhook_url')
?? '';
$department_ids = $response->getRequestParameter('internal_department_ids')
?? $response->getRequestParameter('department_ids')
?? [];
if (!is_array($department_ids)) {
$department_ids = array_filter(array_map('trim', explode(',', (string)$department_ids)));
}
(new logs_o())->add('slack_config', 'global', 1, $user->id, 'SLACK_INTERNAL_DEPARTMENT_GOAL_PROGRESS_CONFIG', 'Successfully updated Slack internal department goal progress config');
$response->success(
(new slack())->set_internal_department_goal_progress_config(
(string)$webhook_url,
$department_ids
)
);
},
[
'slack_config' => 'Update Slack internal department goal progress config'
]
);
$this->get('/backups/config', function () {
global $response;
$this->requirePermission('backups_config');