1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Notifications/Ninja/EmailQuotaNotification.php

82 lines
1.9 KiB
PHP
Raw Normal View History

2021-08-31 13:29:18 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
2021-08-31 13:29:18 +02:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Notifications\Ninja;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
class EmailQuotaNotification extends Notification
2021-08-31 13:29:18 +02:00
{
/**
* Create a new notification instance.
*
* @return void
*/
protected $account;
public function __construct($account)
{
$this->account = $account;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
2023-10-26 04:57:44 +02:00
*
2021-08-31 13:29:18 +02:00
*/
public function toMail($notifiable)
{
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toSlack($notifiable)
{
$content = "Email quota exceeded by Account {$this->account->key} \n";
2024-08-22 08:45:06 +02:00
$owner = $this->account->companies()->first()->owner() ?? $this->account->users()->orderBy('id', 'asc')->first();
2024-02-04 05:06:24 +01:00
$owner_name = $owner->present()->name() ?? 'No Owner Found';
$owner_email = $owner->email ?? 'No Owner Email Found';
2021-08-31 13:29:18 +02:00
2024-02-04 05:06:24 +01:00
$content .= "Owner {$owner_name} | {$owner_email}";
2021-08-31 13:29:18 +02:00
2024-01-14 05:05:00 +01:00
return (new SlackMessage())
2021-08-31 13:29:18 +02:00
->success()
->from(ctrans('texts.notification_bot'))
->image('https://app.invoiceninja.com/favicon.png')
->content($content);
}
}