mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Clean up code.
This commit is contained in:
@@ -37,6 +37,7 @@ use Ntfy\Message;
|
|||||||
class UnknownUserLoginAttempt extends Notification
|
class UnknownUserLoginAttempt extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private string $address;
|
private string $address;
|
||||||
|
|
||||||
public function __construct(string $address)
|
public function __construct(string $address)
|
||||||
@@ -60,28 +61,7 @@ class UnknownUserLoginAttempt extends Notification
|
|||||||
{
|
{
|
||||||
return new MailMessage()
|
return new MailMessage()
|
||||||
->markdown('emails.owner.unknown-user', ['address' => $this->address])
|
->markdown('emails.owner.unknown-user', ['address' => $this->address])
|
||||||
->subject((string) trans('email.unknown_user_subject'))
|
->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'))
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,6 +78,25 @@ class UnknownUserLoginAttempt extends Notification
|
|||||||
return $message;
|
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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
|
@@ -69,30 +69,9 @@ class UserInvitation extends Notification
|
|||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.invitation-created', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])
|
->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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
@@ -108,6 +87,27 @@ class UserInvitation extends Notification
|
|||||||
return $message;
|
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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
|
@@ -69,28 +69,9 @@ class UserRegistration extends Notification
|
|||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.registered-admin', ['email' => $this->user->email, 'id' => $this->user->id])
|
->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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
@@ -106,6 +87,25 @@ class UserRegistration extends Notification
|
|||||||
return $message;
|
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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
|
@@ -66,32 +66,9 @@ class VersionCheckResult extends Notification
|
|||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.new-version', ['message' => $this->message])
|
->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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
@@ -107,6 +84,28 @@ class VersionCheckResult extends Notification
|
|||||||
return $message;
|
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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
|
@@ -31,27 +31,6 @@ use NotificationChannels\Pushover\PushoverReceiver;
|
|||||||
|
|
||||||
class OwnerNotifiable
|
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.
|
* Get the notification routing information for the given driver.
|
||||||
*
|
*
|
||||||
@@ -62,7 +41,7 @@ class OwnerNotifiable
|
|||||||
*/
|
*/
|
||||||
public function routeNotificationFor($driver, $notification = null)
|
public function routeNotificationFor($driver, $notification = null)
|
||||||
{
|
{
|
||||||
$method = 'routeNotificationFor'.Str::studly($driver);
|
$method = 'routeNotificationFor' . Str::studly($driver);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
Log::debug(sprintf('Redirect for settings to "%s".', $method));
|
Log::debug(sprintf('Redirect for settings to "%s".', $method));
|
||||||
|
|
||||||
@@ -75,4 +54,24 @@ class OwnerNotifiable
|
|||||||
default => null,
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ class ReturnsAvailableChannels
|
|||||||
if ('owner' === $type) {
|
if ('owner' === $type) {
|
||||||
return self::returnOwnerChannels();
|
return self::returnOwnerChannels();
|
||||||
}
|
}
|
||||||
if('user' === $type && null !== $user) {
|
if ('user' === $type && null !== $user) {
|
||||||
return self::returnUserChannels($user);
|
return self::returnUserChannels($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +50,8 @@ class ReturnsAvailableChannels
|
|||||||
private static function returnOwnerChannels(): array
|
private static function returnOwnerChannels(): array
|
||||||
{
|
{
|
||||||
|
|
||||||
$channels = ['mail'];
|
$channels = ['mail'];
|
||||||
$slackUrl = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
|
$slackUrl = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
|
||||||
if (UrlValidator::isValidWebhookURL($slackUrl)) {
|
if (UrlValidator::isValidWebhookURL($slackUrl)) {
|
||||||
$channels[] = 'slack';
|
$channels[] = 'slack';
|
||||||
}
|
}
|
||||||
@@ -81,19 +81,20 @@ class ReturnsAvailableChannels
|
|||||||
return $channels;
|
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;
|
$channels = ['mail'];
|
||||||
|
$slackUrl = app('preferences')->getEncryptedForUser($user, 'slack_webhook_url', '')->data;
|
||||||
if (UrlValidator::isValidWebhookURL($slackUrl)) {
|
if (UrlValidator::isValidWebhookURL($slackUrl)) {
|
||||||
$channels[] = 'slack';
|
$channels[] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate presence of of Ntfy settings.
|
// 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.');
|
Log::debug('Enabled ntfy.');
|
||||||
$channels[] = NtfyChannel::class;
|
$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.');
|
Log::warning('No topic name for Ntfy, channel is disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ class ReturnsSettings
|
|||||||
'ntfy_pass' => '',
|
'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_server'] = Preferences::getEncryptedForUser($user, 'ntfy_server', 'https://ntfy.sh')->data;
|
||||||
$settings['ntfy_topic'] = Preferences::getEncryptedForUser($user, 'ntfy_topic', '')->data;
|
$settings['ntfy_topic'] = Preferences::getEncryptedForUser($user, 'ntfy_topic', '')->data;
|
||||||
$settings['ntfy_auth'] = Preferences::getForUser($user, 'ntfy_auth', false)->data;
|
$settings['ntfy_auth'] = Preferences::getForUser($user, 'ntfy_auth', false)->data;
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Security;
|
|||||||
|
|
||||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\Notifications\ReturnsSettings;
|
use FireflyIII\Notifications\ReturnsSettings;
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -46,6 +45,7 @@ class DisabledMFANotification extends Notification
|
|||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
@@ -64,15 +64,21 @@ class DisabledMFANotification extends Notification
|
|||||||
|
|
||||||
return (new MailMessage())->markdown('emails.security.disabled-mfa', ['user' => $this->user])->subject($subject);
|
return (new MailMessage())->markdown('emails.security.disabled-mfa', ['user' => $this->user])->subject($subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
public function toSlack(User $notifiable)
|
public function toNtfy(User $user): Message
|
||||||
{
|
{
|
||||||
$message = (string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]);
|
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
||||||
|
$message = new Message();
|
||||||
|
$message->topic($settings['ntfy_topic']);
|
||||||
|
$message->title((string) trans('email.disabled_mfa_subject'));
|
||||||
|
$message->body((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]));
|
||||||
|
|
||||||
return (new SlackMessage())->content($message);
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
@@ -81,20 +87,17 @@ class DisabledMFANotification extends Notification
|
|||||||
Log::debug('Now in (user) toPushover()');
|
Log::debug('Now in (user) toPushover()');
|
||||||
|
|
||||||
return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]))
|
return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]))
|
||||||
->title((string)trans('email.disabled_mfa_subject'));
|
->title((string) trans('email.disabled_mfa_subject'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
public function toNtfy(User $user): Message
|
public function toSlack(User $notifiable)
|
||||||
{
|
{
|
||||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
$message = (string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]);
|
||||||
$message = new Message();
|
|
||||||
$message->topic($settings['ntfy_topic']);
|
|
||||||
$message->title((string)trans('email.disabled_mfa_subject'));
|
|
||||||
$message->body((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]));
|
|
||||||
|
|
||||||
return $message;
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,7 +35,7 @@ class EnabledMFANotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
@@ -43,42 +43,41 @@ class EnabledMFANotification extends Notification
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function via($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,9 +35,8 @@ class MFABackupFewLeftNotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private int $count;
|
||||||
private int $count;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user, int $count)
|
public function __construct(User $user, int $count)
|
||||||
{
|
{
|
||||||
@@ -45,42 +44,41 @@ class MFABackupFewLeftNotification extends Notification
|
|||||||
$this->count = $count;
|
$this->count = $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function via($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,7 +35,7 @@ class MFABackupNoLeftNotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
@@ -43,42 +43,41 @@ class MFABackupNoLeftNotification extends Notification
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function via($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,9 +35,8 @@ class MFAManyFailedAttemptsNotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private int $count;
|
||||||
private int $count;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user, int $count)
|
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 [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function via($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,7 +35,7 @@ class MFAUsedBackupCodeNotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
@@ -43,42 +43,41 @@ class MFAUsedBackupCodeNotification extends Notification
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function via($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -35,7 +35,7 @@ class NewBackupCodesNotification extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
@@ -43,42 +43,40 @@ class NewBackupCodesNotification extends Notification
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function via($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Security;
|
namespace FireflyIII\Notifications\Security;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
@@ -33,7 +34,7 @@ class UserFailedLoginAttempt extends Notification
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
@@ -42,41 +43,37 @@ class UserFailedLoginAttempt extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toArray($notifiable)
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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);
|
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);
|
return (new SlackMessage())->content($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function via($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
/** @var null|User $user */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,7 @@ class OwnerTestNotificationEmail extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(OwnerNotifiable $notifiable)
|
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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return MailMessage
|
|
||||||
*/
|
*/
|
||||||
public function toMail(OwnerNotifiable $notifiable)
|
public function toMail(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
@@ -72,18 +62,11 @@ class OwnerTestNotificationEmail extends Notification
|
|||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.admin-test', ['email' => $address])
|
->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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function via(OwnerNotifiable $notifiable)
|
public function via(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
|
@@ -49,13 +49,7 @@ class OwnerTestNotificationNtfy extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
@@ -63,6 +57,9 @@ class OwnerTestNotificationNtfy extends Notification
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||||
{
|
{
|
||||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||||
|
@@ -49,11 +49,7 @@ class OwnerTestNotificationPushover extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(OwnerNotifiable $notifiable)
|
public function toArray(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
@@ -61,13 +57,15 @@ class OwnerTestNotificationPushover extends Notification
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
|
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
|
||||||
{
|
{
|
||||||
Log::debug('Now in toPushover()');
|
Log::debug('Now in toPushover()');
|
||||||
|
|
||||||
return PushoverMessage::create((string)trans('email.admin_test_message', ['channel' => 'Pushover']))
|
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
|
||||||
->title((string)trans('email.admin_test_subject'))
|
->title((string) trans('email.admin_test_subject'));
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -47,11 +47,7 @@ class OwnerTestNotificationSlack extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(OwnerNotifiable $notifiable)
|
public function toArray(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
@@ -60,8 +56,6 @@ class OwnerTestNotificationSlack extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Slack representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
public function toSlack(OwnerNotifiable $notifiable)
|
public function toSlack(OwnerNotifiable $notifiable)
|
||||||
@@ -71,11 +65,7 @@ class OwnerTestNotificationSlack extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function via(OwnerNotifiable $notifiable)
|
public function via(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Test;
|
namespace FireflyIII\Notifications\Test;
|
||||||
|
|
||||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -46,11 +45,7 @@ class UserTestNotificationEmail extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(User $notifiable)
|
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)
|
public function toMail(User $notifiable)
|
||||||
{
|
{
|
||||||
$address = (string) $notifiable->email;
|
$address = (string) $notifiable->email;
|
||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.admin-test', ['email' => $address])
|
->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)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @param User $notifiable
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function via(User $notifiable)
|
public function via(User $notifiable)
|
||||||
{
|
{
|
||||||
|
@@ -49,13 +49,7 @@ class UserTestNotificationNtfy extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @param User $notifiable
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(User $notifiable)
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
@@ -63,10 +57,13 @@ class UserTestNotificationNtfy extends Notification
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
public function toNtfy(User $user): Message
|
public function toNtfy(User $user): Message
|
||||||
{
|
{
|
||||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
||||||
$message = new Message();
|
$message = new Message();
|
||||||
$message->topic($settings['ntfy_topic']);
|
$message->topic($settings['ntfy_topic']);
|
||||||
$message->title((string) trans('email.admin_test_subject'));
|
$message->title((string) trans('email.admin_test_subject'));
|
||||||
$message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
$message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
||||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\Test;
|
namespace FireflyIII\Notifications\Test;
|
||||||
|
|
||||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
@@ -50,11 +49,7 @@ class UserTestNotificationPushover extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(User $notifiable)
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
@@ -62,13 +57,15 @@ class UserTestNotificationPushover extends Notification
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
public function toPushover(User $notifiable): PushoverMessage
|
public function toPushover(User $notifiable): PushoverMessage
|
||||||
{
|
{
|
||||||
Log::debug('Now in (user) toPushover()');
|
Log::debug('Now in (user) toPushover()');
|
||||||
|
|
||||||
return PushoverMessage::create((string)trans('email.admin_test_message', ['channel' => 'Pushover']))
|
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
|
||||||
->title((string)trans('email.admin_test_subject'))
|
->title((string) trans('email.admin_test_subject'));
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -40,18 +40,16 @@ class UserTestNotificationSlack extends Notification
|
|||||||
|
|
||||||
private OwnerNotifiable $owner;
|
private OwnerNotifiable $owner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
public function __construct(OwnerNotifiable $owner)
|
public function __construct(OwnerNotifiable $owner)
|
||||||
{
|
{
|
||||||
$this->owner = $owner;
|
$this->owner = $owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(OwnerNotifiable $notifiable)
|
public function toArray(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
@@ -60,8 +58,6 @@ class UserTestNotificationSlack extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Slack representation of the notification.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
public function toSlack(OwnerNotifiable $notifiable)
|
public function toSlack(OwnerNotifiable $notifiable)
|
||||||
@@ -71,11 +67,7 @@ class UserTestNotificationSlack extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function via(OwnerNotifiable $notifiable)
|
public function via(OwnerNotifiable $notifiable)
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -52,58 +52,55 @@ class BillReminder extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toArray($notifiable)
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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) {
|
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())
|
return (new MailMessage())
|
||||||
->markdown('emails.bill-warning', ['field' => $this->field, 'diff' => $this->diff, 'bill' => $this->bill])
|
->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) {
|
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;
|
$bill = $this->bill;
|
||||||
$url = route('bills.show', [$bill->id]);
|
$url = route('bills.show', [$bill->id]);
|
||||||
|
|
||||||
return (new SlackMessage())
|
return (new SlackMessage())
|
||||||
->warning()
|
->warning()
|
||||||
->attachment(static function ($attachment) use ($bill, $url): void {
|
->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 */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -42,40 +42,35 @@ class NewAccessToken extends Notification
|
|||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
|
|
||||||
|
|
||||||
public function toArray($notifiable)
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toMail($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toMail(User $notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.token-created')
|
->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 */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
@@ -47,22 +47,26 @@ class RuleActionFailed extends Notification
|
|||||||
public function __construct(array $params)
|
public function __construct(array $params)
|
||||||
{
|
{
|
||||||
[$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink] = $params;
|
[$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink] = $params;
|
||||||
$this->message = $mainMessage;
|
$this->message = $mainMessage;
|
||||||
$this->groupTitle = $groupTitle;
|
$this->groupTitle = $groupTitle;
|
||||||
$this->groupLink = $groupLink;
|
$this->groupLink = $groupLink;
|
||||||
$this->ruleTitle = $ruleTitle;
|
$this->ruleTitle = $ruleTitle;
|
||||||
$this->ruleLink = $ruleLink;
|
$this->ruleLink = $ruleLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toSlack($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toSlack(User $notifiable)
|
||||||
{
|
{
|
||||||
$groupTitle = $this->groupTitle;
|
$groupTitle = $this->groupTitle;
|
||||||
$groupLink = $this->groupLink;
|
$groupLink = $this->groupLink;
|
||||||
@@ -70,28 +74,19 @@ class RuleActionFailed extends Notification
|
|||||||
$ruleLink = $this->ruleLink;
|
$ruleLink = $this->ruleLink;
|
||||||
|
|
||||||
return (new SlackMessage())->content($this->message)->attachment(static function ($attachment) use ($groupTitle, $groupLink): void {
|
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(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 */
|
// todo disable mail channel
|
||||||
$user = auth()->user();
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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 [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
@@ -43,25 +45,33 @@ class TransactionCreation extends Notification
|
|||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
|
||||||
public function toMail($notifiable)
|
public function toMail(User $notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.report-new-journals', ['transformed' => $this->collection])
|
->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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Support\Notifications\UrlValidator;
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
@@ -48,16 +48,18 @@ class UserLogin extends Notification
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toArray($notifiable)
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
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 = '';
|
$host = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -72,12 +74,13 @@ class UserLogin extends Notification
|
|||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $host])
|
->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 = '';
|
$host = '';
|
||||||
|
|
||||||
@@ -91,22 +94,14 @@ class UserLogin extends Notification
|
|||||||
$host = $hostName;
|
$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 */
|
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
@@ -43,25 +45,30 @@ class UserNewPassword extends Notification
|
|||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toMail($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toMail(User $notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.password', ['url' => $this->url])
|
->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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Notifications\User;
|
namespace FireflyIII\Notifications\User;
|
||||||
|
|
||||||
|
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
@@ -38,25 +40,30 @@ class UserRegistration extends Notification
|
|||||||
|
|
||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toArray($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toArray(User $notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function toMail($notifiable)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
*/
|
||||||
|
public function toMail(User $notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('emails.registered', ['address' => route('index')])
|
->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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user