kopia lustrzana https://github.com/newroco/mail2deck
reply to sender with newly created card, fixes #13
rodzic
77f99de5bb
commit
e616ebfffb
|
@ -73,9 +73,12 @@ if ($emails)
|
|||
$data->description = $description;
|
||||
$mailSender = new stdClass();
|
||||
$mailSender->userId = $overview->from[0]->mailbox;
|
||||
$mailSender = 'alex.puiu';
|
||||
|
||||
$newcard = new DeckClass();
|
||||
$newcard->addCard($data, $mailSender);
|
||||
$response = $newcard->addCard($data, $mailSender);
|
||||
$mailSender->userId .= "@{$overview->from[0]->host}";
|
||||
if($response && ASSIGN_SENDER) {
|
||||
$inbox->reply($mailSender->userId, $response);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
class DeckClass {
|
||||
private $responseCode;
|
||||
|
||||
private function apiCall($request, $endpoint, $data = null, $attachment = false){
|
||||
$curl = curl_init();
|
||||
if($data && !$attachment) {
|
||||
|
@ -25,6 +27,7 @@ class DeckClass {
|
|||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
$this->responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($curl);
|
||||
if($err) echo "cURL Error #:" . $err;
|
||||
|
@ -46,6 +49,7 @@ class DeckClass {
|
|||
foreach($boards as $board) {
|
||||
if(strtolower($board->title) == strtolower($boardFromMail)) {
|
||||
$boardId = $board->id;
|
||||
$boardName = $board->title;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +63,7 @@ class DeckClass {
|
|||
$boardStack->board = $boardId;
|
||||
$boardStack->stack = $stackId;
|
||||
$boardStack->newTitle = $params;
|
||||
$boardStack->boardTitle = $boardName;
|
||||
|
||||
return $boardStack;
|
||||
}
|
||||
|
@ -69,10 +74,14 @@ class DeckClass {
|
|||
$card = $this->apiCall("POST", NC_SERVER . "/index.php/apps/deck/api/v1.0/boards/{$params->board}/stacks/{$params->stack}/cards", $data);
|
||||
$card->board = $params->board;
|
||||
$card->stack = $params->stack;
|
||||
if(ASSIGN_SENDER) {
|
||||
$this->assignUser($card, $user);
|
||||
|
||||
if($this->responseCode == 200) {
|
||||
if(ASSIGN_SENDER) $this->assignUser($card, $user);
|
||||
if($data->attachments) $this->addAttachments($card, $data->attachments);
|
||||
$card->boardTitle = $params->boardTitle;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if($data->attachments) $this->addAttachments($card, $data->attachments);
|
||||
|
||||
return $card;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,22 @@ class MailClass {
|
|||
}
|
||||
|
||||
public function reply($sender, $response) {
|
||||
$to = $sender->mailbox . '@' . $sender->host;
|
||||
mail($to, 'your card has been created', 'card/board link.....');
|
||||
$serverName = parse_url(NC_SERVER);
|
||||
|
||||
$headers = array(
|
||||
'From' => 'no-reply@' . $serverName['host'],
|
||||
'MIME-Version' => '1.0',
|
||||
'Content-Type' => 'text/html'
|
||||
);
|
||||
|
||||
$message = "<html>";
|
||||
$message .= "<head><title>You created a new issue on board {$response->boardTitle}.</title></head>";
|
||||
$message .= "<body>";
|
||||
$message .= "<h1>You created a new issue on board {$response->boardTitle}.</h1>";
|
||||
$message .= "<p>Check out this <a href=\"" . NC_SERVER . "/index.php/apps/deck/#/board/{$response->board}/card/{$response->id}" . "\">link</a> to see your newly created card.</p>";
|
||||
$message .= "</body>";
|
||||
$message .= "</html>";
|
||||
|
||||
mail($sender, 'An issue has been reported!', $message, $headers);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue