Clean up for spam notifications

This commit is contained in:
David Bomba 2022-08-01 17:17:06 +10:00
parent e63d99c2d1
commit ad7889b769
2 changed files with 12 additions and 11 deletions

View File

@ -29,7 +29,7 @@ class SpamNotification extends Notification
* @return void * @return void
*/ */
protected array $spam_list; public array $spam_list;
public function __construct($spam_list) public function __construct($spam_list)
{ {
@ -74,43 +74,45 @@ class SpamNotification extends Notification
{ {
$content = ''; $content = '';
foreach($this->spam_list as $spam_list) // foreach($this->spam_lists as $spam_list)
{ // {
if(array_key_exists('companies', $spam_list)) if(array_key_exists('companies', $this->spam_list))
{ {
$content .= " Companies \n"; $content .= " Companies \n";
foreach($spam_list['companies'] as $company) foreach($this->spam_list['companies'] as $company)
{ {
$content .= "{$company['name']} - c_key={$company['company_key']} - a_key={$company['account_key']} - {$company['owner']} \n"; $content .= "{$company['name']} - c_key={$company['company_key']} - a_key={$company['account_key']} - {$company['owner']} \n";
} }
} }
if(array_key_exists('templates', $spam_list)) if(array_key_exists('templates', $this->spam_list))
{ {
$content .= " Templates \n"; $content .= " Templates \n";
foreach($spam_list['templates'] as $company) foreach($this->spam_list['templates'] as $company)
{ {
$content .= "{$company['name']} - c_key={$company['company_key']} - a_key={$company['account_key']} - {$company['owner']} \n"; $content .= "{$company['name']} - c_key={$company['company_key']} - a_key={$company['account_key']} - {$company['owner']} \n";
} }
} }
if(array_key_exists('users', $spam_list)) if(array_key_exists('users', $this->spam_list))
{ {
$content .= ' Users \n'; $content .= ' Users \n';
foreach($spam_list['users'] as $user) foreach($this->spam_list['users'] as $user)
{ {
$content .= "{$user['email']} - a_key={$user['account_key']} - created={$user['created']} \n"; $content .= "{$user['email']} - a_key={$user['account_key']} - created={$user['created']} \n";
} }
} }
} // }
return (new SlackMessage) return (new SlackMessage)
->success() ->success()

View File

@ -70,7 +70,6 @@ class NotificationService extends AbstractService
public function ninja() public function ninja()
{ {
Notification::route('slack', config('ninja.notification.slack')) Notification::route('slack', config('ninja.notification.slack'))
->route('mail', config('ninja.notification.mail'))
->notify($this->notification); ->notify($this->notification);
} }
} }