mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Add better exception handling for emails
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Admin;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Notification\Receiver;
|
use Alchemy\Phrasea\Notification\Receiver;
|
||||||
use Alchemy\Phrasea\Notification\Mail\MailTest;
|
use Alchemy\Phrasea\Notification\Mail\MailTest;
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -187,7 +188,12 @@ class Dashboard implements ControllerProviderInterface
|
|||||||
$app->abort(400, 'Bad request missing email parameter');
|
$app->abort(400, 'Bad request missing email parameter');
|
||||||
};
|
};
|
||||||
|
|
||||||
$receiver = new Receiver(null, $mail);
|
try {
|
||||||
|
$receiver = new Receiver(null, $mail);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
return $app->redirect('/admin/dashboard/?email=not-sent');
|
||||||
|
}
|
||||||
|
|
||||||
$mail = MailTest::create($app, $receiver);
|
$mail = MailTest::create($app, $receiver);
|
||||||
|
|
||||||
$app['notification.deliverer']->deliver($mail);
|
$app['notification.deliverer']->deliver($mail);
|
||||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
|||||||
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Alchemy\Phrasea\Notification\Emitter;
|
use Alchemy\Phrasea\Notification\Emitter;
|
||||||
use Alchemy\Phrasea\Notification\Receiver;
|
use Alchemy\Phrasea\Notification\Receiver;
|
||||||
use Alchemy\Phrasea\Notification\Mail\MailRecordsExport;
|
use Alchemy\Phrasea\Notification\Mail\MailRecordsExport;
|
||||||
@@ -285,7 +286,11 @@ class Export implements ControllerProviderInterface
|
|||||||
$emitter = new Emitter($app['phraseanet.user']->get_display_name(), $app['phraseanet.user']->get_email());
|
$emitter = new Emitter($app['phraseanet.user']->get_display_name(), $app['phraseanet.user']->get_email());
|
||||||
|
|
||||||
foreach ($destMails as $key => $mail) {
|
foreach ($destMails as $key => $mail) {
|
||||||
$receiver = new Receiver(null, trim($mail));
|
try {
|
||||||
|
$receiver = new Receiver(null, trim($mail));
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$mail = MailRecordsExport::create($app, $receiver, $emitter, $request->request->get('textmail'));
|
$mail = MailRecordsExport::create($app, $receiver, $emitter, $request->request->get('textmail'));
|
||||||
$mail->setButtonUrl($url);
|
$mail->setButtonUrl($url);
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Helper\User;
|
namespace Alchemy\Phrasea\Helper\User;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
|
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
|
||||||
use Alchemy\Phrasea\Notification\Receiver;
|
use Alchemy\Phrasea\Notification\Receiver;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -539,15 +540,27 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
$new_email = $user->get_email();
|
$new_email = $user->get_email();
|
||||||
|
|
||||||
if ($old_email != $new_email) {
|
if ($old_email != $new_email) {
|
||||||
|
try {
|
||||||
|
$oldReceiver = new Receiver(null, $old_email);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
|
||||||
$newReceiver = new Receiver(null, $new_email);
|
}
|
||||||
$oldReceiver = new Receiver(null, $old_email);
|
|
||||||
|
|
||||||
$mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, sprintf(_('You will now receive notifications at %s'), $new_email));
|
if ($oldReceiver) {
|
||||||
$mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, sprintf(_('You will no longer receive notifications at %s'), $old_email));
|
$mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, sprintf(_('You will now receive notifications at %s'), $new_email));
|
||||||
|
$this->app['notification.deliverer']->deliver($mailOldAddress);
|
||||||
|
}
|
||||||
|
|
||||||
$this->app['notification.deliverer']->deliver($mailOldAddress);
|
try {
|
||||||
$this->app['notification.deliverer']->deliver($mailNewAddress);
|
$newReceiver = new Receiver(null, $new_email);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($newReceiver) {
|
||||||
|
$mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, sprintf(_('You will no longer receive notifications at %s'), $old_email));
|
||||||
|
$this->app['notification.deliverer']->deliver($mailNewAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessFTP;
|
use Alchemy\Phrasea\Notification\Mail\MailSuccessFTP;
|
||||||
use Alchemy\Phrasea\Notification\Receiver;
|
use Alchemy\Phrasea\Notification\Receiver;
|
||||||
|
|
||||||
@@ -658,17 +659,31 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$sender_message = $text_mail_sender . $message;
|
$sender_message = $text_mail_sender . $message;
|
||||||
$receiver_message = $text_mail_receiver . $message;
|
$receiver_message = $text_mail_receiver . $message;
|
||||||
|
|
||||||
$receiver = new Receiver(null, $sendermail);
|
$receiver = null;
|
||||||
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $sender_message);
|
try {
|
||||||
$mail->setServer($ftp_server);
|
$receiver = new Receiver(null, $sendermail);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
|
||||||
$this->dependencyContainer['notification.deliverer']->deliver($mail);
|
}
|
||||||
|
|
||||||
$receiver = new Receiver(null, $mail);
|
if ($receiver) {
|
||||||
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $receiver_message);
|
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $sender_message);
|
||||||
$mail->setServer($ftp_server);
|
$mail->setServer($ftp_server);
|
||||||
|
$this->dependencyContainer['notification.deliverer']->deliver($mail);
|
||||||
|
}
|
||||||
|
|
||||||
$this->dependencyContainer['notification.deliverer']->deliver($mail);
|
$receiver = null;
|
||||||
|
try {
|
||||||
|
$receiver = new Receiver(null, $mail);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($receiver) {
|
||||||
|
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $receiver_message);
|
||||||
|
$mail->setServer($ftp_server);
|
||||||
|
$this->dependencyContainer['notification.deliverer']->deliver($mail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logexport(record_adapter $record, $obj, $ftpLog)
|
public function logexport(record_adapter $record, $obj, $ftpLog)
|
||||||
|
Reference in New Issue
Block a user