Add user based bots and policy
All checks were successful
Deploy App / deploy (push) Successful in 9s
All checks were successful
Deploy App / deploy (push) Successful in 9s
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bots;
|
||||
|
||||
use App\Bots\BotContract;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Mattermost implements BotContract
|
||||
{
|
||||
protected Client $client;
|
||||
|
||||
public function __construct(private ?array $config = [])
|
||||
{
|
||||
$this->client = new Client([
|
||||
'base_uri' => rtrim(config('scheduler.mattermost.server_url'), '/') . '/api/v4/',
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('scheduler.mattermost.access_token'),
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
try {
|
||||
$this->client->request(
|
||||
$this->config['method'] ?? 'POST',
|
||||
$this->config['endpoint'],
|
||||
[
|
||||
'json' => json_decode($this->config['body'] ?? '', true),
|
||||
]
|
||||
);
|
||||
} catch (GuzzleException $e) {
|
||||
Log::error("Call to Mattermost failed. " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function configSchema(): array
|
||||
{
|
||||
return [
|
||||
'endpoint' => [
|
||||
'type' => 'string',
|
||||
'label' => 'API Endpoint',
|
||||
'rules' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
]
|
||||
],
|
||||
'method' => [
|
||||
'type' => 'string',
|
||||
'label' => 'HTTP Method',
|
||||
'default' => 'POST',
|
||||
'rules' => [
|
||||
'required',
|
||||
'in:GET,POST,PUT,DELETE,PATCH',
|
||||
]
|
||||
],
|
||||
'body' => [
|
||||
'type' => 'json',
|
||||
'label' => 'Request Body (JSON)',
|
||||
'rules' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'json',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user