Merge branch 'fixes/fix-send-mail-cc-app-admin' into staging
This commit is contained in:
commit
3a690ed967
@ -8,7 +8,7 @@ abstract class BddConstant
|
||||
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "admin";
|
||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann";
|
||||
|
||||
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\DB\Exception;
|
||||
@ -94,10 +95,6 @@ class InvoiceController extends Controller
|
||||
{
|
||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureClientMail = $this->gestionRepository->getFactureClientMailByFactureId($factureId);
|
||||
if($factureClientMail == null){
|
||||
return new DataResponse("Le mail de la facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->currentUserIdNextcloud);
|
||||
if($factureGeneratedResponse == null){
|
||||
return new DataResponse("La facture n'a pas été générée correctement", 404, ['Content-Type' => 'application/json']);
|
||||
@ -119,9 +116,9 @@ class InvoiceController extends Controller
|
||||
"<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>".
|
||||
$signature
|
||||
);
|
||||
$authUserEmail = $this->user->getEMailAddress();
|
||||
if ($authUserEmail) {
|
||||
$message->setCc([$authUserEmail]);
|
||||
$appAdminEmail = $this->gestionRepository->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||
if ($appAdminEmail) {
|
||||
$message->setCc([$appAdminEmail]);
|
||||
}
|
||||
|
||||
$this->mailer->send($message);
|
||||
|
||||
@ -1619,9 +1619,9 @@ class PageController extends Controller {
|
||||
$signature
|
||||
);
|
||||
|
||||
$authUserEmail = $this->user->getEMailAddress();
|
||||
if ($authUserEmail) {
|
||||
$message->setCc([$authUserEmail]);
|
||||
$appAdminEmail = $this->myDb->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||
if ($appAdminEmail) {
|
||||
$message->setCc([$appAdminEmail]);
|
||||
}
|
||||
$this->mailer->send($message);
|
||||
return new DataResponse("", 200, ['Content-Type' => 'application/json']);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
namespace OCA\Gestion\Db;
|
||||
|
||||
use \Datetime;
|
||||
use OCA\Gestion\Helpers\MailHelpers;
|
||||
use OCP\IL10N;
|
||||
use OCP\IDBConnection;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -5147,4 +5148,24 @@ COMMENTAIRES: ".$comment;
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
private function getUserAccountDataByNextcloudId($nextcloudId)
|
||||
{
|
||||
$sql = "SELECT * FROM " . self::DEFAULT_TABLE_PREFIX . "accounts as user_account WHERE user_account.uid = ? LIMIT 1;";
|
||||
$result = $this->execSQLNoJsonReturn($sql, [$nextcloudId]);
|
||||
if (!empty($result)) {
|
||||
return $result[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getUserEmailByNextcloudId($nextcloudId)
|
||||
{
|
||||
$userAccount = $this->getUserAccountDataByNextcloudId($nextcloudId);
|
||||
if ($userAccount != null) {
|
||||
$userEmail = MailHelpers::getUserMailFromUserAccountData($userAccount['data']);
|
||||
return $userEmail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
18
gestion/lib/Helpers/MailHelpers.php
Normal file
18
gestion/lib/Helpers/MailHelpers.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\Gestion\Helpers;
|
||||
|
||||
|
||||
class MailHelpers
|
||||
{
|
||||
public static function getUserMailFromUserAccountData(string $userAccountData): string|null
|
||||
{
|
||||
$userAccountData = json_decode($userAccountData, true);
|
||||
if (isset($userAccountData['email']) && isset($userAccountData['email']['value'])) {
|
||||
return $userAccountData['email']['value'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user