Files
backupscript/src/Notification/Ntfy.php

33 lines
682 B
PHP
Raw Normal View History

2023-06-12 09:30:10 +00:00
<?php
namespace App\Notification;
use Ntfy\Server;
use Ntfy\Message;
use Ntfy\Client;
class Ntfy implements NotificationInterface
{
private array $config;
private \Ntfy\Server $server;
private \Ntfy\Client $client;
public function __construct(array $config)
{
$this->config = $config;
$this->server = new Server($config['domain']);
$this->client = new Client($this->server);
}
public function send(string $title, string $message): void
{
$msg = new Message();
$msg->topic($this->config['topic']);
$msg->title($title);
$msg->body($message);
$this->client->send($msg);
}
}