Clean up code.

This commit is contained in:
James Cole
2024-12-14 07:22:46 +01:00
parent b3560ff525
commit 5f1502eea7
30 changed files with 432 additions and 505 deletions

View File

@@ -37,6 +37,7 @@ use Ntfy\Message;
class UnknownUserLoginAttempt extends Notification
{
use Queueable;
private string $address;
public function __construct(string $address)
@@ -60,28 +61,7 @@ class UnknownUserLoginAttempt extends Notification
{
return new MailMessage()
->markdown('emails.owner.unknown-user', ['address' => $this->address])
->subject((string) trans('email.unknown_user_subject'))
;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable): SlackMessage
{
return new SlackMessage()->content(
(string) trans('email.unknown_user_body', ['address' => $this->address])
);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
return PushoverMessage::create((string) trans('email.unknown_user_message', ['address' => $this->address]))
->title((string) trans('email.unknown_user_subject'))
;
->subject((string) trans('email.unknown_user_subject'));
}
/**
@@ -98,6 +78,25 @@ class UnknownUserLoginAttempt extends Notification
return $message;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
return PushoverMessage::create((string) trans('email.unknown_user_message', ['address' => $this->address]))
->title((string) trans('email.unknown_user_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable): SlackMessage
{
return new SlackMessage()->content(
(string) trans('email.unknown_user_body', ['address' => $this->address])
);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/

View File

@@ -69,30 +69,9 @@ class UserInvitation extends Notification
{
return (new MailMessage())
->markdown('emails.invitation-created', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])
->subject((string) trans('email.invitation_created_subject'))
;
->subject((string) trans('email.invitation_created_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content(
(string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])
);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for UserInvitation');
return PushoverMessage::create((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]))
->title((string) trans('email.invitation_created_subject'))
;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
@@ -108,6 +87,27 @@ class UserInvitation extends Notification
return $message;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for UserInvitation');
return PushoverMessage::create((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]))
->title((string) trans('email.invitation_created_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content(
(string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])
);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/

View File

@@ -69,28 +69,9 @@ class UserRegistration extends Notification
{
return (new MailMessage())
->markdown('emails.registered-admin', ['email' => $this->user->email, 'id' => $this->user->id])
->subject((string) trans('email.registered_subject_admin'))
;
->subject((string) trans('email.registered_subject_admin'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'id' => $this->user->id]));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for UserRegistration');
return PushoverMessage::create((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email]))
->title((string) trans('email.registered_subject_admin'))
;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
@@ -106,6 +87,25 @@ class UserRegistration extends Notification
return $message;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for UserRegistration');
return PushoverMessage::create((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email]))
->title((string) trans('email.registered_subject_admin'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'id' => $this->user->id]));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/

View File

@@ -66,32 +66,9 @@ class VersionCheckResult extends Notification
{
return (new MailMessage())
->markdown('emails.new-version', ['message' => $this->message])
->subject((string)trans('email.new_version_email_subject'))
;
->subject((string) trans('email.new_version_email_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content($this->message)
->attachment(static function ($attachment): void {
$attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
})
;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for VersionCheckResult');
return PushoverMessage::create($this->message)
->title((string) trans('email.new_version_email_subject'))
;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
@@ -107,6 +84,28 @@ class VersionCheckResult extends Notification
return $message;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover() for VersionCheckResult');
return PushoverMessage::create($this->message)
->title((string) trans('email.new_version_email_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
{
return (new SlackMessage())->content($this->message)
->attachment(static function ($attachment): void {
$attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
});
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/

View File

@@ -31,27 +31,6 @@ use NotificationChannels\Pushover\PushoverReceiver;
class OwnerNotifiable
{
public function routeNotificationForSlack(): string
{
$res = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}
return (string) $res;
}
public function routeNotificationForPushover()
{
Log::debug('Return settings for routeNotificationForPushover');
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken)
;
}
/**
* Get the notification routing information for the given driver.
*
@@ -62,7 +41,7 @@ class OwnerNotifiable
*/
public function routeNotificationFor($driver, $notification = null)
{
$method = 'routeNotificationFor'.Str::studly($driver);
$method = 'routeNotificationFor' . Str::studly($driver);
if (method_exists($this, $method)) {
Log::debug(sprintf('Redirect for settings to "%s".', $method));
@@ -75,4 +54,24 @@ class OwnerNotifiable
default => null,
};
}
public function routeNotificationForPushover()
{
Log::debug('Return settings for routeNotificationForPushover');
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken);
}
public function routeNotificationForSlack(): string
{
$res = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}
return (string) $res;
}
}

View File

@@ -39,7 +39,7 @@ class ReturnsAvailableChannels
if ('owner' === $type) {
return self::returnOwnerChannels();
}
if('user' === $type && null !== $user) {
if ('user' === $type && null !== $user) {
return self::returnUserChannels($user);
}
@@ -81,7 +81,8 @@ class ReturnsAvailableChannels
return $channels;
}
private static function returnUserChannels(User $user): array {
private static function returnUserChannels(User $user): array
{
$channels = ['mail'];
$slackUrl = app('preferences')->getEncryptedForUser($user, 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
@@ -89,11 +90,11 @@ class ReturnsAvailableChannels
}
// validate presence of of Ntfy settings.
if ('' !== (string) app('preferences')->getEncryptedForUser($user,'ntfy_topic', '')->data) {
if ('' !== (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
Log::debug('Enabled ntfy.');
$channels[] = NtfyChannel::class;
}
if ('' === (string) app('preferences')->getEncryptedForUser($user,'ntfy_topic', '')->data) {
if ('' === (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
Log::warning('No topic name for Ntfy, channel is disabled.');
}

View File

@@ -50,7 +50,7 @@ class ReturnsSettings
'ntfy_pass' => '',
];
if('user' === $type && null !== $user) {
if ('user' === $type && null !== $user) {
$settings['ntfy_server'] = Preferences::getEncryptedForUser($user, 'ntfy_server', 'https://ntfy.sh')->data;
$settings['ntfy_topic'] = Preferences::getEncryptedForUser($user, 'ntfy_topic', '')->data;
$settings['ntfy_auth'] = Preferences::getForUser($user, 'ntfy_auth', false)->data;

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Security;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\Notifications\ReturnsSettings;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -46,6 +45,7 @@ class DisabledMFANotification extends Notification
{
$this->user = $user;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
@@ -64,25 +64,7 @@ class DisabledMFANotification extends Notification
return (new MailMessage())->markdown('emails.security.disabled-mfa', ['user' => $this->user])->subject($subject);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(User $notifiable): PushoverMessage
{
Log::debug('Now in (user) toPushover()');
return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]))
->title((string)trans('email.disabled_mfa_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
@@ -91,12 +73,33 @@ class DisabledMFANotification extends Notification
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
$message = new Message();
$message->topic($settings['ntfy_topic']);
$message->title((string)trans('email.disabled_mfa_subject'));
$message->title((string) trans('email.disabled_mfa_subject'));
$message->body((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]));
return $message;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(User $notifiable): PushoverMessage
{
Log::debug('Now in (user) toPushover()');
return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]))
->title((string) trans('email.disabled_mfa_subject'));
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -43,42 +43,41 @@ class EnabledMFANotification extends Notification
$this->user = $user;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.enabled_mfa_subject');
$subject = (string) trans('email.enabled_mfa_subject');
return (new MailMessage())->markdown('emails.security.enabled-mfa', ['user' => $this->user])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.enabled_mfa_slack', ['email' => $this->user->email]);
$message = (string) trans('email.enabled_mfa_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -35,9 +35,8 @@ class MFABackupFewLeftNotification extends Notification
{
use Queueable;
private User $user;
private int $count;
private User $user;
public function __construct(User $user, int $count)
{
@@ -45,42 +44,41 @@ class MFABackupFewLeftNotification extends Notification
$this->count = $count;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.mfa_few_backups_left_subject', ['count' => $this->count]);
$subject = (string) trans('email.mfa_few_backups_left_subject', ['count' => $this->count]);
return (new MailMessage())->markdown('emails.security.few-backup-codes', ['user' => $this->user, 'count' => $this->count])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);
$message = (string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -43,42 +43,41 @@ class MFABackupNoLeftNotification extends Notification
$this->user = $user;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.mfa_no_backups_left_subject');
$subject = (string) trans('email.mfa_no_backups_left_subject');
return (new MailMessage())->markdown('emails.security.no-backup-codes', ['user' => $this->user])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);
$message = (string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -35,9 +35,8 @@ class MFAManyFailedAttemptsNotification extends Notification
{
use Queueable;
private User $user;
private int $count;
private User $user;
public function __construct(User $user, int $count)
{
@@ -46,41 +45,38 @@ class MFAManyFailedAttemptsNotification extends Notification
}
public function toArray($notifiable)
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.mfa_many_failed_subject', ['count' => $this->count]);
$subject = (string) trans('email.mfa_many_failed_subject', ['count' => $this->count]);
return (new MailMessage())->markdown('emails.security.many-failed-attempts', ['user' => $this->user, 'count' => $this->count])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);
$message = (string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -43,42 +43,41 @@ class MFAUsedBackupCodeNotification extends Notification
$this->user = $user;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.used_backup_code_subject');
$subject = (string) trans('email.used_backup_code_subject');
return (new MailMessage())->markdown('emails.security.used-backup-code', ['user' => $this->user])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.used_backup_code_slack', ['email' => $this->user->email]);
$message = (string) trans('email.used_backup_code_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -43,42 +43,40 @@ class NewBackupCodesNotification extends Notification
$this->user = $user;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.new_backup_codes_subject');
$subject = (string) trans('email.new_backup_codes_subject');
return (new MailMessage())->markdown('emails.security.new-backup-codes', ['user' => $this->user])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
$message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -23,7 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Security;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -42,41 +43,37 @@ class UserFailedLoginAttempt extends Notification
}
public function toArray($notifiable)
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans('email.new_backup_codes_subject');
$subject = (string) trans('email.new_backup_codes_subject');
return (new MailMessage())->markdown('emails.security.new-backup-codes', ['user' => $this->user])->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
$message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
return (new SlackMessage())->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -45,11 +45,7 @@ class OwnerTestNotificationEmail extends Notification
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(OwnerNotifiable $notifiable)
{
@@ -58,13 +54,7 @@ class OwnerTestNotificationEmail extends Notification
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return MailMessage
*/
public function toMail(OwnerNotifiable $notifiable)
{
@@ -72,18 +62,11 @@ class OwnerTestNotificationEmail extends Notification
return (new MailMessage())
->markdown('emails.admin-test', ['email' => $address])
->subject((string) trans('email.admin_test_subject'))
;
->subject((string) trans('email.admin_test_subject'));
}
/**
* Get the notification's delivery channels.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param mixed $notifiable
*
* @return array
*/
public function via(OwnerNotifiable $notifiable)
{

View File

@@ -49,13 +49,7 @@ class OwnerTestNotificationNtfy extends Notification
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray($notifiable)
{
@@ -63,6 +57,9 @@ class OwnerTestNotificationNtfy extends Notification
];
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toNtfy(OwnerNotifiable $notifiable): Message
{
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);

View File

@@ -49,11 +49,7 @@ class OwnerTestNotificationPushover extends Notification
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(OwnerNotifiable $notifiable)
{
@@ -61,13 +57,15 @@ class OwnerTestNotificationPushover extends Notification
];
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{
Log::debug('Now in toPushover()');
return PushoverMessage::create((string)trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string)trans('email.admin_test_subject'))
;
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string) trans('email.admin_test_subject'));
}
/**

View File

@@ -47,11 +47,7 @@ class OwnerTestNotificationSlack extends Notification
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(OwnerNotifiable $notifiable)
{
@@ -60,8 +56,6 @@ class OwnerTestNotificationSlack extends Notification
}
/**
* Get the Slack representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
@@ -71,11 +65,7 @@ class OwnerTestNotificationSlack extends Notification
}
/**
* Get the notification's delivery channels.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function via(OwnerNotifiable $notifiable)
{

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Test;
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -46,11 +45,7 @@ class UserTestNotificationEmail extends Notification
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(User $notifiable)
{
@@ -58,33 +53,18 @@ class UserTestNotificationEmail extends Notification
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return MailMessage
*/
public function toMail(User $notifiable)
{
$address = (string) $notifiable->email;
return (new MailMessage())
->markdown('emails.admin-test', ['email' => $address])
->subject((string) trans('email.admin_test_subject'))
;
->subject((string) trans('email.admin_test_subject'));
}
/**
* Get the notification's delivery channels.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param User $notifiable
*
* @return array
*/
public function via(User $notifiable)
{

View File

@@ -49,13 +49,7 @@ class UserTestNotificationNtfy extends Notification
}
/**
* Get the array representation of the notification.
*
* @param User $notifiable
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(User $notifiable)
{
@@ -63,6 +57,9 @@ class UserTestNotificationNtfy extends Notification
];
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toNtfy(User $user): Message
{
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Test;
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
@@ -50,11 +49,7 @@ class UserTestNotificationPushover extends Notification
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(User $notifiable)
{
@@ -62,13 +57,15 @@ class UserTestNotificationPushover extends Notification
];
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toPushover(User $notifiable): PushoverMessage
{
Log::debug('Now in (user) toPushover()');
return PushoverMessage::create((string)trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string)trans('email.admin_test_subject'))
;
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string) trans('email.admin_test_subject'));
}
/**

View File

@@ -40,18 +40,16 @@ class UserTestNotificationSlack extends Notification
private OwnerNotifiable $owner;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(OwnerNotifiable $owner)
{
$this->owner = $owner;
}
/**
* Get the array representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function toArray(OwnerNotifiable $notifiable)
{
@@ -60,8 +58,6 @@ class UserTestNotificationSlack extends Notification
}
/**
* Get the Slack representation of the notification.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(OwnerNotifiable $notifiable)
@@ -71,11 +67,7 @@ class UserTestNotificationSlack extends Notification
}
/**
* Get the notification's delivery channels.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
public function via(OwnerNotifiable $notifiable)
{

View File

@@ -25,7 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Models\Bill;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -52,32 +52,38 @@ class BillReminder extends Notification
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$subject = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
$subject = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
if (0 === $this->diff) {
$subject = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
$subject = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
}
return (new MailMessage())
->markdown('emails.bill-warning', ['field' => $this->field, 'diff' => $this->diff, 'bill' => $this->bill])
->subject($subject)
;
->subject($subject);
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$message = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
$message = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
if (0 === $this->diff) {
$message = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
$message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
}
$bill = $this->bill;
$url = route('bills.show', [$bill->id]);
@@ -85,25 +91,16 @@ class BillReminder extends Notification
return (new SlackMessage())
->warning()
->attachment(static function ($attachment) use ($bill, $url): void {
$attachment->title((string)trans('firefly.visit_bill', ['name' => $bill->name]), $url);
$attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);
})
->content($message)
;
->content($message);
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -42,40 +42,35 @@ class NewAccessToken extends Notification
public function __construct() {}
public function toArray($notifiable)
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
return (new MailMessage())
->markdown('emails.token-created')
->subject((string)trans('email.access_token_created_subject'))
;
->subject((string) trans('email.access_token_created_subject'));
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
return (new SlackMessage())->content((string)trans('email.access_token_created_body'));
return (new SlackMessage())->content((string) trans('email.access_token_created_body'));
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -54,15 +54,19 @@ class RuleActionFailed extends Notification
$this->ruleLink = $ruleLink;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$groupTitle = $this->groupTitle;
$groupLink = $this->groupLink;
@@ -70,28 +74,19 @@ class RuleActionFailed extends Notification
$ruleLink = $this->ruleLink;
return (new SlackMessage())->content($this->message)->attachment(static function ($attachment) use ($groupTitle, $groupLink): void {
$attachment->title((string)trans('rules.inspect_transaction', ['title' => $groupTitle]), $groupLink);
$attachment->title((string) trans('rules.inspect_transaction', ['title' => $groupTitle]), $groupLink);
})->attachment(static function ($attachment) use ($ruleTitle, $ruleLink): void {
$attachment->title((string)trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);
$attachment->title((string) trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);
});
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
app('log')->debug('Will send ruleActionFailed through Slack or Discord!');
return ['slack'];
}
app('log')->debug('Will NOT send ruleActionFailed through Slack or Discord');
return [];
// todo disable mail channel
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -43,25 +45,33 @@ class TransactionCreation extends Notification
$this->collection = $collection;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
public function toMail(User $notifiable)
{
return (new MailMessage())
->markdown('emails.report-new-journals', ['transformed' => $this->collection])
->subject(trans_choice('email.new_journals_subject', count($this->collection)))
;
->subject(trans_choice('email.new_journals_subject', count($this->collection)));
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
return ['mail'];
// todo only over email?
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -25,7 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
@@ -48,16 +48,18 @@ class UserLogin extends Notification
}
public function toArray($notifiable)
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
$time = now(config('app.timezone'))->isoFormat((string)trans('config.date_time_js'));
$time = now(config('app.timezone'))->isoFormat((string) trans('config.date_time_js'));
$host = '';
try {
@@ -72,12 +74,13 @@ class UserLogin extends Notification
return (new MailMessage())
->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $host])
->subject((string)trans('email.login_from_new_ip'))
;
->subject((string) trans('email.login_from_new_ip'));
}
public function toSlack($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack(User $notifiable)
{
$host = '';
@@ -91,22 +94,14 @@ class UserLogin extends Notification
$host = $hostName;
}
return (new SlackMessage())->content((string)trans('email.slack_login_from_new_ip', ['host' => $host, 'ip' => $this->ip]));
return (new SlackMessage())->content((string) trans('email.slack_login_from_new_ip', ['host' => $host, 'ip' => $this->ip]));
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -43,25 +45,30 @@ class UserNewPassword extends Notification
$this->url = $url;
}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
return (new MailMessage())
->markdown('emails.password', ['url' => $this->url])
->subject((string)trans('email.reset_pw_subject'))
;
->subject((string) trans('email.reset_pw_subject'));
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}

View File

@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -38,25 +40,30 @@ class UserRegistration extends Notification
public function __construct() {}
public function toArray($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray(User $notifiable)
{
return [
];
}
public function toMail($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail(User $notifiable)
{
return (new MailMessage())
->markdown('emails.registered', ['address' => route('index')])
->subject((string)trans('email.registered_subject'))
;
->subject((string) trans('email.registered_subject'));
}
public function via($notifiable)
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via(User $notifiable)
{
return ['mail'];
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
}
}