Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@
"DOMAIN_OA" => "@oa",
"DOMAIN_CA" => "@ca"
]);
define("MAIL_SUPPORT","");//If not empty, use this value to send to the Support team: card url, the description and who submitted the request.
define("MAIL_SUPPORT","");//If not empty, use this value to send to the Support team: card url, the description and who submitted the request.

define("ROCKETCHAT_WEBHOOK", ""); //add rocketchat notification webhook
31 changes: 30 additions & 1 deletion lib/CreateCardClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function createCard($newcard, $data, $mailSender, $cleanedSubject, $inbox, $boar
$response = $newcard->addCard($data, $mailSender->origin, $mailSender->host, $board);
error_log("New card created with response: " . json_encode($response));

if ($response && defined('ROCKETCHAT_WEBHOOK')){
$this->notifyRocketChat($response);
}

if($data->attachments){
$imageUrls = $newcard->addAttachments($response, $data->attachments);
if (!empty($imageUrls)) {
Expand All @@ -106,4 +110,29 @@ function createCard($newcard, $data, $mailSender, $cleanedSubject, $inbox, $boar
error_log("Comment added with response: " . json_encode($response));
}
}
}

function notifyRocketChat($card){
$cardUrl = NC_SERVER . "/index.php/apps/deck/board/{$card->board}/card/{$card->id}";
$boardTitle = $card->boardTitle ?? "Deck";
$payload = json_encode([
'text' => "New ticket on **{$boardTitle}**\n[{$card->title}]({$cardUrl})"
]);

$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => ROCKETCHAT_WEBHOOK,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_TIMEOUT => 5,
]);

$resp = curl_exec($curl);
if (curl_errno($curl)) {
error_log("RocketChat notify error: " . curl_error($curl));
}

curl_close($curl);
}
}