all the various fixes to make update_redmine work

This commit is contained in:
Jon Goldberg 2020-07-31 17:39:49 -04:00
parent 1925b5b4b0
commit 9c0a5603d3
No known key found for this signature in database
GPG Key ID: C2D2247364F9DB13
3 changed files with 8 additions and 8 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
contact.txt contact.txt
users.csv users.csv
oncallbot.jpg oncallbot.jpg
.vscode

View File

@ -79,7 +79,7 @@ class oncall {
// Debug Mode will show more information. // Debug Mode will show more information.
$this->debugMode = (bool) getenv('DEBUG_MODE'); $this->debugMode = (bool) getenv('DEBUG_MODE');
$this->baseUrl = getenv('REDMINE_URL'); $this->baseUrl = getenv('REDMINE_URL');
$this->apiKey = getenv('KEY'); $this->apiKey = getenv('REDMINE_API_KEY');
// FIXME: Not using $this->apiKey. // FIXME: Not using $this->apiKey.
$this->queries = [ $this->queries = [

View File

@ -1,4 +1,3 @@
#!/usr/bin/php
<?php <?php
declare(strict_types = 1); declare(strict_types = 1);
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
@ -63,15 +62,15 @@ class update_redmine {
// Debug Mode will show more information. // Debug Mode will show more information.
$this->debugMode = (bool) getenv('DEBUG_MODE'); $this->debugMode = (bool) getenv('DEBUG_MODE');
$this->baseUrl = getenv('REDMINE_URL'); $this->baseUrl = getenv('REDMINE_URL');
$this->apiKey = getenv('KEY'); $this->apiKey = getenv('REDMINE_API_KEY');
$this->setAction($action); $this->setAction($_GET['action']);
} }
public function setAction($action) { public function setAction($action) {
$validActions = [ $validActions = [
'do_not_alert' => 'PUT', 'do_not_alert' => 'PUT',
]; ];
if ($validActions['$action'] ?? FALSE) { if ($validActions[$action] ?? FALSE) {
$this->action = $action; $this->action = $action;
$this->httpMethod = $validActions[$action]; $this->httpMethod = $validActions[$action];
} }
@ -83,10 +82,10 @@ class update_redmine {
public function prepareAction() { public function prepareAction() {
if ($this->action === 'do_not_alert') { if ($this->action === 'do_not_alert') {
$this->json = '{"issue": {"custom_fields": [{"id": 4, "value": "1"}]}}'; $this->json = '{"issue": {"custom_fields": [{"id": 4, "value": "1"}]}}';
if (is_int($_GET['issue'])) { if (is_numeric($_GET['issue'])) {
$issue = $GET['issue']; $issue = $_GET['issue'];
} }
$this->fullUrl = $this->baseUrl . "/$issue.json"; $this->fullUrl = $this->baseUrl . "/issues/$issue.json";
} }
} }