Add user based bots and policy
All checks were successful
Deploy App / deploy (push) Successful in 9s

This commit is contained in:
2025-08-31 14:27:42 +02:00
parent ed74c14f8d
commit 75be85e608
8 changed files with 69 additions and 78 deletions

View File

@@ -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',
]
],
];
}
}