mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup.
This commit is contained in:
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Notifications\User\NewAccessToken;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
@@ -36,13 +35,11 @@ class APIEventHandler
|
||||
{
|
||||
/**
|
||||
* Respond to the creation of an access token.
|
||||
*
|
||||
* @param AccessTokenCreated $event
|
||||
*
|
||||
*/
|
||||
public function accessTokenCreated(AccessTokenCreated $event): void
|
||||
{
|
||||
app('log')->debug(__METHOD__);
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find((int)$event->userId);
|
||||
@@ -50,14 +47,16 @@ class APIEventHandler
|
||||
if (null !== $user) {
|
||||
try {
|
||||
Notification::send($user, new NewAccessToken());
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
} catch (\Exception $e) { // @phpstan-ignore-line
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (str_contains($message, 'RFC 2822')) {
|
||||
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error($e->getMessage());
|
||||
|
Reference in New Issue
Block a user