mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- sqlite support (default database). - add custom theme color option. - sidebar can be collapsed to use the full screen. - option to switch navigation to top bar instead of sidebar. - option to remove top bar completely. - option to add breadcrumbs - option to enable single page application mode (website feels like an app instead of loading page ) - add highest and lowest price (for the plugin mainly) - new settings for NTFY_CHANNEL_ID instead of passing whole link. - removed name field from create operation, with url autofocused, so you can paste the links faster. - custom settings are shared across the stores. - new filters in products. - removed dashboard page. - RSS feed added - notifications will have tags to know why you have been notified, along with highest and lowest price. Fixes: - Fetch works properly and live, please note it will fetch all the stores related, won't use queue anymore. (overusing it might block you) Removed: - groups. Technical Changes: - update money cast to round values. - remove update product details, since it's only used in one place. - remove is_store methods, easier to scale with new stores - created proper ntfy channel - all stores will go with key pivot value, instead of each store having its own column in database.
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\NotificationsChannels;
|
|
|
|
|
|
use Exception;
|
|
use GuzzleHttp\Client as HttpClient;
|
|
use GuzzleHttp\Exception\RequestException;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Facades\Http;
|
|
use NotificationChannels\Discord\Exceptions\CouldNotSendNotification;
|
|
|
|
|
|
class Ntfy
|
|
{
|
|
protected string $baseUrl = 'https://ntfy.sh/';
|
|
|
|
protected $httpClient;
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
$this->httpClient = new Http();
|
|
}
|
|
|
|
|
|
public function send( array $notification_title , string $notification_content )
|
|
{
|
|
return $this->request($notification_title , $notification_content);
|
|
}
|
|
|
|
|
|
protected function request( array $notification_title, string $notification_content)
|
|
{
|
|
$auth=[];
|
|
$url=$this->baseUrl . env('NTFY_CHANNEL_ID');
|
|
|
|
if (env("NTFY_USER") && env("NTFY_PASSWORD"))
|
|
$auth["Authorization"] = "Basic " . base64_encode(env("NTFY_USER") .":" . env("NTFY_PASSWORD") );
|
|
elseif (env("NTFY_TOKEN"))
|
|
$auth["Authorization"] = "Bearer " . env("NTFY_TOKEN");
|
|
|
|
$response = Http::withHeaders($auth + [
|
|
"Content-Type"=>"text/markdown",
|
|
'X-Markdown'=>"1",
|
|
'Markdown'=>"1",
|
|
'md'=>"1",
|
|
"Cache: no",
|
|
] + $notification_title)
|
|
->post($url, $notification_content);
|
|
|
|
$body = json_decode($response->getBody(), true);
|
|
|
|
return $body;
|
|
}
|
|
|
|
}
|