2 Commits

Author SHA1 Message Date
61b52d8427 troys issues funktion 2025-02-15 21:02:11 +01:00
b475672eac erster versuch 2025-02-15 20:32:58 +01:00
3 changed files with 39 additions and 34 deletions

View File

@@ -8,6 +8,8 @@ $_m['data'] = '';
$_m['pre'] = '';
$_m['salt'] = '';
$_m['issuedata'] = ['domain'=>'','secret'=>''];
$_sendermail = 'noreply@.de';
$_smtp['srv'] = 'mail.seemsleg.it';
$_smtp['user'] = 'noreply@.de';

View File

@@ -4,6 +4,7 @@ class SQL {
private $res = false;
private $m;
public $salt;
public $issuedata;
public $pre;
public $cnt_get = 0;
public $cnt_set = 0;
@@ -11,6 +12,7 @@ class SQL {
require_once ('secret.php');
$this->m = $_m;
$this->issuedata = $_m['issuedata'];
$this->pre = $_m ['pre'];
$this->salt = $_m ['salt'];
if (SQL_LOG)

View File

@@ -14,36 +14,37 @@ function sendToTroy($data) {
return file_get_contents ( $url, false, $context );
}
function sendToGitea($title, $message) {
// secret.php liegt in lib/
require 'secret.php';
function troysIssue($ident, $typ, $text = null, $data = [], $reaction = []) {
global $sql;
$url = "https://issues.troy-grunt.de/api/input";
$url = rtrim($giteaUrl, '/') . "/repos/$giteaOwner/$giteaRepo/issues";
$data = [
"title" => $title,
"body" => $message
$payload = [
"domain" => $sql->issuedata['domain'],
"secret" => $sql->issuedata['secret'],
"ident" => $ident,
"typ" => $typ,
"text" => $text,
"data" => $data,
"reaction" => $reaction
];
// Entferne null-Werte aus dem Array
$payload = array_filter($payload, function ($value) {
return $value !== null;
});
$options = [
'http' => [
'method' => 'POST',
'header' => [
"Content-Type: application/json",
"Authorization: token $giteaToken"
],
'content' => json_encode($data)
"http" => [
"header" => "Content-Type: application/json\r\n",
"method" => "POST",
"content" => json_encode($payload),
"ignore_errors" => true
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
throw new Exception("Fehler beim Erstellen der Anfrage");
}
return json_decode($result, true);
}
?>