Skip to content

Commit 5803f81

Browse files
committed
fixed #34
1 parent e686eda commit 5803f81

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=5.6.4",
26-
"laravel/framework": ">=5.4",
25+
"php": ">=7.0",
26+
"laravel/framework": ">=5.5",
2727
"guzzlehttp/guzzle": ">=6.0",
2828
"jenssegers/agent": "2.6.*"
2929
},

src/Listeners/NotifyUsers.php

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
namespace Akaunting\Firewall\Listeners;
44

55
use Akaunting\Firewall\Events\AttackDetected as Event;
6-
use Akaunting\Firewall\Notifications\AttackDetected as Notification;
7-
use Exception;
8-
use GuzzleHttp\Exception\RequestException;
9-
use Illuminate\Notifications\Notifiable;
6+
use Akaunting\Firewall\Notifications\AttackDetected;
7+
use Akaunting\Firewall\Notifications\Notifiable;
108
use Throwable;
119

1210
class NotifyUsers
@@ -20,34 +18,10 @@ class NotifyUsers
2018
*/
2119
public function handle(Event $event)
2220
{
23-
$notifiable = $this->getNotifiableClass();
24-
2521
try {
26-
$notifiable->notify(new Notification($event->log));
27-
} catch (Exception | RequestException | Throwable $e) {
22+
(new Notifiable)->notify(new AttackDetected($event->log));
23+
} catch (Throwable $e) {
2824
report($e);
2925
}
3026
}
31-
32-
protected function getNotifiableClass()
33-
{
34-
return new class() {
35-
use Notifiable;
36-
37-
public function routeNotificationForMail()
38-
{
39-
return config('firewall.notifications.mail.to');
40-
}
41-
42-
public function routeNotificationForSlack()
43-
{
44-
return config('firewall.notifications.slack.to');
45-
}
46-
47-
public function getKey()
48-
{
49-
return 1;
50-
}
51-
};
52-
}
5327
}

src/Notifications/Notifiable.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Akaunting\Firewall\Notifications;
4+
5+
use Illuminate\Notifications\Notifiable as NotifiableTrait;
6+
7+
class Notifiable
8+
{
9+
use NotifiableTrait;
10+
11+
public function routeNotificationForMail()
12+
{
13+
return config('firewall.notifications.mail.to');
14+
}
15+
16+
public function routeNotificationForSlack()
17+
{
18+
return config('firewall.notifications.slack.to');
19+
}
20+
21+
public function getKey()
22+
{
23+
return 1;
24+
}
25+
}

0 commit comments

Comments
 (0)