mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix extra notification
This commit is contained in:
@@ -25,6 +25,7 @@ namespace FireflyIII\Notifications\User;
|
||||
use Exception;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class UserLogin extends Notification
|
||||
@@ -51,7 +52,7 @@ class UserLogin extends Notification
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
return ['mail', 'slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,6 +79,27 @@ class UserLogin extends Notification
|
||||
->subject((string) trans('email.login_from_new_ip'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Slack representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$host = '';
|
||||
try {
|
||||
$hostName = gethostbyaddr($this->ip);
|
||||
} catch (Exception $e) {
|
||||
$hostName = $this->ip;
|
||||
}
|
||||
if ($hostName !== $this->ip) {
|
||||
$host = $hostName;
|
||||
}
|
||||
|
||||
return (new SlackMessage)->content((string) trans('email.slack_login_from_new_ip', ['host' => $host, 'ip' => $this->ip]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
|
Reference in New Issue
Block a user