* slack and google calendar feature flags * cs fix * update .env.example
This commit is contained in:
@@ -4,22 +4,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Channels;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Toby\Domain\Notifications\Notifiable;
|
||||
|
||||
class SlackApiChannel
|
||||
{
|
||||
public function send(Notifiable $notifiable, Notification $notification): Response
|
||||
public function send(Notifiable $notifiable, Notification $notification): void
|
||||
{
|
||||
if (!config("services.slack.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
$url = "{$baseUrl}/chat.postMessage";
|
||||
$channel = $notifiable->routeNotificationFor("slack", $notification);
|
||||
|
||||
$message = $notification->toSlack($notifiable);
|
||||
|
||||
return Http::withToken($this->getClientToken())
|
||||
Http::withToken($this->getClientToken())
|
||||
->post($url, array_merge($message->getPayload(), [
|
||||
"channel" => $channel,
|
||||
]));
|
||||
|
Reference in New Issue
Block a user