Initial work
This commit is contained in:
46
app/Bots/Mattermost/RemoveStatus.php
Normal file
46
app/Bots/Mattermost/RemoveStatus.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bots\Mattermost;
|
||||
|
||||
use App\Bots\BotContract;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RemoveStatus 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'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
try {
|
||||
$res = $this->client->delete('users/me/status/custom');
|
||||
|
||||
if ($res->getStatusCode() === 200) {
|
||||
Log::info("Mattermost status cleared");
|
||||
} else {
|
||||
Log::error("Failed to update Mattermost status. HTTP Status: " . $res->getStatusCode());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Error updating Mattermost status: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function configSchema(): array
|
||||
{
|
||||
return [
|
||||
'endpoint' => ['type' => 'string', 'label' => 'API Endpoint'],
|
||||
'method' => ['type' => 'string', 'label' => 'HTTP Method', 'default' => 'POST'],
|
||||
'body' => ['type' => 'array', 'label' => 'Request Body (JSON)'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user