mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -72,16 +72,6 @@ class MFABackupFewLeftNotification extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.few-backup-codes', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -103,6 +93,16 @@ class MFABackupFewLeftNotification extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -70,16 +70,6 @@ class MFABackupNoLeftNotification extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.no-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -101,6 +91,16 @@ class MFABackupNoLeftNotification extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -69,16 +69,6 @@ class MFAManyFailedAttemptsNotification extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.many-failed-attempts', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -100,6 +90,16 @@ class MFAManyFailedAttemptsNotification extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -70,16 +70,6 @@ class MFAUsedBackupCodeNotification extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.used-backup-code', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.used_backup_code_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -101,6 +91,16 @@ class MFAUsedBackupCodeNotification extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.used_backup_code_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -70,16 +70,6 @@ class NewBackupCodesNotification extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.new-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -101,6 +91,16 @@ class NewBackupCodesNotification extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -67,16 +67,6 @@ class UserFailedLoginAttempt extends Notification
|
||||
return (new MailMessage())->markdown('emails.security.failed-login', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.failed_login_message', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -98,6 +88,16 @@ class UserFailedLoginAttempt extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$message = (string) trans('email.failed_login_message', ['email' => $this->user->email]);
|
||||
|
||||
return new SlackMessage()->content($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -73,21 +73,14 @@ class BillReminder extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
private function getSubject(): string
|
||||
{
|
||||
$bill = $this->bill;
|
||||
$url = route('bills.show', [$bill->id]);
|
||||
$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]);
|
||||
}
|
||||
|
||||
return new SlackMessage()
|
||||
->warning()
|
||||
->attachment(static function ($attachment) use ($bill, $url): void {
|
||||
$attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);
|
||||
})
|
||||
->content($this->getSubject())
|
||||
;
|
||||
return $message;
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
@@ -111,14 +104,21 @@ class BillReminder extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
private function getSubject(): string
|
||||
/**
|
||||
* @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]);
|
||||
if (0 === $this->diff) {
|
||||
$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]);
|
||||
|
||||
return $message;
|
||||
return new SlackMessage()
|
||||
->warning()
|
||||
->attachment(static function ($attachment) use ($bill, $url): void {
|
||||
$attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);
|
||||
})
|
||||
->content($this->getSubject())
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -67,14 +67,6 @@ class NewAccessToken extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
return new SlackMessage()->content((string) trans('email.access_token_created_body'));
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -96,6 +88,14 @@ class NewAccessToken extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
return new SlackMessage()->content((string) trans('email.access_token_created_body'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -65,23 +65,6 @@ class RuleActionFailed extends Notification
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$groupTitle = $this->groupTitle;
|
||||
$groupLink = $this->groupLink;
|
||||
$ruleTitle = $this->ruleTitle;
|
||||
$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(static function ($attachment) use ($ruleTitle, $ruleLink): void {
|
||||
$attachment->title((string) trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);
|
||||
});
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -100,6 +83,23 @@ class RuleActionFailed extends Notification
|
||||
return PushoverMessage::create($this->message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
$groupTitle = $this->groupTitle;
|
||||
$groupLink = $this->groupLink;
|
||||
$ruleTitle = $this->ruleTitle;
|
||||
$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(static function ($attachment) use ($ruleTitle, $ruleLink): void {
|
||||
$attachment->title((string) trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
|
@@ -75,14 +75,6 @@ class UserNewPassword extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
return new SlackMessage()->content((string) trans('email.reset_pw_message'));
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
@@ -101,6 +93,14 @@ class UserNewPassword extends Notification
|
||||
return PushoverMessage::create((string) trans('email.reset_pw_message'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function toSlack(User $notifiable)
|
||||
{
|
||||
return new SlackMessage()->content((string) trans('email.reset_pw_message'));
|
||||
}
|
||||
|
||||
public function via(User $notifiable)
|
||||
{
|
||||
return ReturnsAvailableChannels::returnChannels('user', $notifiable);
|
||||
|
Reference in New Issue
Block a user