mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Update translations and notifications.
This commit is contained in:
@@ -26,7 +26,9 @@ use Exception;
|
||||
use FireflyIII\Events\AdminRequestedTestMessage;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Mail\AdminTestMail;
|
||||
use FireflyIII\Notifications\Admin\TestNotification;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Session;
|
||||
@@ -49,38 +51,13 @@ class AdminEventHandler
|
||||
{
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
|
||||
// is user even admin?
|
||||
if ($repository->hasRole($event->user, 'owner')) {
|
||||
$email = $event->user->email;
|
||||
|
||||
// if user is demo user, send to owner:
|
||||
if ($event->user->hasRole('demo')) {
|
||||
$email = config('firefly.site_owner');
|
||||
}
|
||||
|
||||
// see if user has alternative email address:
|
||||
$pref = app('preferences')->getForUser($event->user, 'remote_guard_alt_email');
|
||||
if (null !== $pref) {
|
||||
$email = $pref->data;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Now in sendTestMessage event handler. Email is %s', $email));
|
||||
try {
|
||||
Log::debug('Trying to send message...');
|
||||
Mail::to($email)->send(new AdminTestMail($email));
|
||||
|
||||
// Laravel cannot pretend this process failed during testing.
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::debug('Send message failed! :(');
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
Session::flash('error', 'Possible email error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
Log::debug('If no error above this line, message was sent.');
|
||||
// do some validation.
|
||||
if (!$repository->hasRole($event->user, 'owner')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Notification::send($event->user, new TestNotification($event->user->email));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,13 +40,11 @@ class AdminTestMail extends Mailable
|
||||
public string $email;
|
||||
|
||||
/**
|
||||
* ConfirmEmailChangeMail constructor.
|
||||
*
|
||||
* @param string $email
|
||||
* AdminTestMail constructor.
|
||||
*/
|
||||
public function __construct(string $email)
|
||||
public function __construct()
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* TestNotification.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
@@ -21,7 +22,64 @@
|
||||
|
||||
namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
class TestNotification
|
||||
{
|
||||
use FireflyIII\Mail\AdminTestMail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
/**
|
||||
* Class TestNotification
|
||||
*/
|
||||
class TestNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private string $address;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->markdown('emails.admin-test', ['email' => $this->address])
|
||||
->subject((string) trans('email.admin_test_subject'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserInvitation.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserRegistration.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* VersionCheckResult.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* BillReminder.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* NewAccessToken.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* TransactionCreation.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserLogin.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserNewEmail.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserNewEmailUndo.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* UserNewPassword.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
|
||||
30
app/User.php
30
app/User.php
@@ -57,8 +57,10 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\DatabaseNotification;
|
||||
use Illuminate\Notifications\DatabaseNotificationCollection;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Passport\Client;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Laravel\Passport\Token;
|
||||
@@ -545,5 +547,31 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->hasMany(Webhook::class);
|
||||
}
|
||||
// end LDAP related code
|
||||
|
||||
/**
|
||||
* Get the notification routing information for the given driver.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param Notification|null $notification
|
||||
* @return mixed
|
||||
*/
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
{
|
||||
if (method_exists($this, $method = 'routeNotificationFor' . Str::studly($driver))) {
|
||||
return $this->{$method}($notification);
|
||||
}
|
||||
$email = $this->email;
|
||||
// see if user has alternative email address:
|
||||
$pref = app('preferences')->getForUser($this, 'remote_guard_alt_email');
|
||||
if (null !== $pref) {
|
||||
$email = $pref->data;
|
||||
}
|
||||
|
||||
return match ($driver) {
|
||||
'database' => $this->notifications(),
|
||||
'mail' => $email,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -685,9 +685,6 @@ class FireflyValidator extends Validator
|
||||
$trigger = 0;
|
||||
$response = 0;
|
||||
$delivery = 0;
|
||||
|
||||
|
||||
|
||||
$triggers = Webhook::getTriggersForValidation();
|
||||
$responses = Webhook::getResponsesForValidation();
|
||||
$deliveries = Webhook::getDeliveriesForValidation();
|
||||
|
||||
Reference in New Issue
Block a user