mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
if email couldn't sended make warning not error and transmit to login-server
This commit is contained in:
parent
d842884490
commit
d2497c9c7c
@ -387,6 +387,10 @@ class JsonRequestHandlerController extends AppController {
|
||||
//echo "after validate <br>";
|
||||
|
||||
if ($transaction->save()) {
|
||||
$result = ['state' => 'success'];
|
||||
if($transaction->hasWarnings()) {
|
||||
$result['warnings'] = $transaction->getWarnings();
|
||||
}
|
||||
// success
|
||||
return $this->returnJson(['state' => 'success']);
|
||||
} else {
|
||||
|
||||
@ -25,7 +25,7 @@ class Transaction extends TransactionBase {
|
||||
//$transactionBin = base64_decode($base64Data, true);
|
||||
//if($transactionBin == false) {
|
||||
//sodium_base64_VARIANT_URLSAFE_NO_PADDING
|
||||
if(is_a($base64Data, '\Proto\Gradido\Transaction')) {
|
||||
if(is_a($base64Data, '\Proto\Gradido\GradidoTransaction')) {
|
||||
$this->mProtoTransaction = $base64Data;
|
||||
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
|
||||
return;
|
||||
@ -93,7 +93,11 @@ class Transaction extends TransactionBase {
|
||||
return $this->mTransactionBody;
|
||||
}
|
||||
|
||||
public function getFirstPublic() {
|
||||
public function getFirstPublic()
|
||||
{
|
||||
if(!$this->mProtoTransaction || !$this->mProtoTransaction->getSigMap()) {
|
||||
return '';
|
||||
}
|
||||
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
|
||||
return $sigPairs[0]->getPubKey();
|
||||
}
|
||||
@ -111,6 +115,7 @@ class Transaction extends TransactionBase {
|
||||
$sigMap = $this->mProtoTransaction->getSigMap();
|
||||
if(!$sigMap) {
|
||||
$this->addError('Transaction', 'signature map is zero');
|
||||
//var_dump($this->mProtoTransaction);
|
||||
return false;
|
||||
}
|
||||
//var_dump($sigMap);
|
||||
@ -193,8 +198,10 @@ class Transaction extends TransactionBase {
|
||||
|
||||
$connection->commit();
|
||||
|
||||
$this->mTransactionBody->getSpecificTransaction()->sendNotificationEmail($this->mTransactionBody->getMemo());
|
||||
$specificTransaction = $this->mTransactionBody->getSpecificTransaction();
|
||||
|
||||
$specificTransaction->sendNotificationEmail($this->mTransactionBody->getMemo());
|
||||
$this->addWarnings($specificTransaction->getWarnings());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -6,24 +6,38 @@ use Cake\ORM\TableRegistry;
|
||||
|
||||
class TransactionBase {
|
||||
private $errors = [];
|
||||
private $warnings = [];
|
||||
static $tables = [];
|
||||
|
||||
public function getErrors() {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
public function getWarnings() {
|
||||
return $this->warnings;
|
||||
}
|
||||
public function addError($functionName, $errorName) {
|
||||
array_push($this->errors, [$functionName => $errorName]);
|
||||
}
|
||||
public function addWarning($functionName, $warningName) {
|
||||
$this->warnings[] = [$functionName => $warningName];
|
||||
}
|
||||
|
||||
public function addErrors($errors) {
|
||||
$this->errors = array_merge($this->errors, $errors);
|
||||
}
|
||||
|
||||
public function addWarnings($warnings) {
|
||||
$this->warnings = array_merge($this->warnings, $warnings);
|
||||
}
|
||||
|
||||
public function hasErrors() {
|
||||
return count($this->errors) > 0;
|
||||
}
|
||||
|
||||
public function hasWarnings() {
|
||||
return count($this->warnings) > 0;
|
||||
}
|
||||
public static function getTable($tableName) {
|
||||
if(!isset(self::$tables[$tableName])) {
|
||||
self::$tables[$tableName] = TableRegistry::getTableLocator()->get($tableName);
|
||||
|
||||
@ -209,6 +209,7 @@ class TransactionCreation extends TransactionBase {
|
||||
->send();
|
||||
} catch(Exception $e) {
|
||||
// $this->addError('TransactionCreation::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
$this->addWarning('TransactionCreation::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -211,6 +211,7 @@ class TransactionTransfer extends TransactionBase {
|
||||
->send();
|
||||
} catch(Exception $e) {
|
||||
//$this->addError('TransactionTransfer::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
$this->addWarning('TransactionTransfer::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user