. */ declare(strict_types=1); namespace FireflyIII\Notifications\Test; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; //use Illuminate\Notifications\Slack\SlackMessage; use Illuminate\Support\Facades\Log; use Illuminate\Notifications\Messages\SlackMessage; /** * Class TestNotification */ class TestNotificationSlack extends Notification { use Queueable; private OwnerNotifiable $owner; /** * Create a new notification instance. */ public function __construct(OwnerNotifiable $owner) { $this->owner =$owner; } /** * Get the array representation of the notification. * * @param OwnerNotifiable $notifiable * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * @return array */ public function toArray(OwnerNotifiable $notifiable) { return [ ]; } /** * Get the Slack representation of the notification. * * @param OwnerNotifiable $notifiable * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * */ public function toSlack(OwnerNotifiable $notifiable) { // since it's an admin notification, grab the URL from fireflyconfig $url = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data; if ('' !== $url) { return new SlackMessage()->content((string)trans('email.admin_test_subject'))->to($url); //return new SlackMessage()->text((string) trans('email.admin_test_subject'))->to($url); } Log::error('Empty slack URL, cannot send notification.'); } /** * Get the notification's delivery channels. * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * @param OwnerNotifiable $notifiable * * @return array */ public function via(OwnerNotifiable $notifiable) { return ['slack']; } }