mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Channels;
|
|
|
|
use Helpers;
|
|
use Http;
|
|
use Illuminate\Mail\Markdown;
|
|
use Illuminate\Notifications\Notification;
|
|
use Log;
|
|
|
|
class PushPlusChannel
|
|
{
|
|
public function send($notifiable, Notification $notification)
|
|
{
|
|
$message = $notification->toCustom($notifiable);
|
|
|
|
$response = Http::timeout(15)->post('https://www.pushplus.plus/send', [
|
|
'token' => sysConfig('pushplus_token'),
|
|
'title' => $message['title'],
|
|
'content' => Markdown::parse($message['content'])->toHtml(),
|
|
'template' => 'html',
|
|
]);
|
|
|
|
// 发送成功
|
|
if ($response->ok()) {
|
|
$ret = $response->json();
|
|
if ($ret['code'] === 200) {
|
|
Helpers::addNotificationLog($message['title'], $message['content'], 7);
|
|
|
|
return $ret;
|
|
}
|
|
// 发送失败
|
|
Helpers::addNotificationLog($message['title'], $message['content'], 7, -1, $ret ? $ret['msg'] : trans('common.status.unknown'));
|
|
|
|
return false;
|
|
}
|
|
// 发送错误
|
|
Log::critical(trans('notification.error', ['channel' => trans('admin.system.notification.channel.pushplus'), 'reason' => var_export($response, true)]));
|
|
|
|
return false;
|
|
}
|
|
}
|