* slack and google calendar feature flags * cs fix * update .env.example
This commit is contained in:
parent
31a6d287c8
commit
68e32ad930
@ -57,11 +57,13 @@ DOCKER_INSTALL_XDEBUG=false
|
|||||||
|
|
||||||
GOOGLE_CLIENT_ID=
|
GOOGLE_CLIENT_ID=
|
||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
|
GOOGLE_CALENDAR_ENABLED=true
|
||||||
GOOGLE_REDIRECT=http://localhost/login/google/end
|
GOOGLE_REDIRECT=http://localhost/login/google/end
|
||||||
GOOGLE_CALENDAR_ID=
|
GOOGLE_CALENDAR_ID=
|
||||||
LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE=
|
LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE=
|
||||||
|
|
||||||
SLACK_URL=https://slack.com/api
|
SLACK_URL=https://slack.com/api
|
||||||
|
SLACK_ENABLED=true
|
||||||
SLACK_CLIENT_TOKEN=
|
SLACK_CLIENT_TOKEN=
|
||||||
SLACK_SIGNING_SECRET=
|
SLACK_SIGNING_SECRET=
|
||||||
SLACK_DEFAULT_CHANNEL="#general"
|
SLACK_DEFAULT_CHANNEL="#general"
|
||||||
|
@ -21,6 +21,10 @@ class ClearVacationRequestDaysInGoogleCalendar implements ShouldQueue
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
|
if (!config("services.google.calendar_enabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->vacationRequest->event_ids ?? [] as $eventId) {
|
foreach ($this->vacationRequest->event_ids ?? [] as $eventId) {
|
||||||
$calendarEvent = Event::find($eventId);
|
$calendarEvent = Event::find($eventId);
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ class SendVacationRequestDaysToGoogleCalendar implements ShouldQueue
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
|
if (!config("services.google.calendar_enabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$days = $this->vacationRequest
|
$days = $this->vacationRequest
|
||||||
->vacations()
|
->vacations()
|
||||||
->orderBy("date")
|
->orderBy("date")
|
||||||
|
@ -4,22 +4,25 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Slack\Channels;
|
namespace Toby\Infrastructure\Slack\Channels;
|
||||||
|
|
||||||
use Illuminate\Http\Client\Response;
|
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Toby\Domain\Notifications\Notifiable;
|
use Toby\Domain\Notifications\Notifiable;
|
||||||
|
|
||||||
class SlackApiChannel
|
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();
|
$baseUrl = $this->getBaseUrl();
|
||||||
$url = "{$baseUrl}/chat.postMessage";
|
$url = "{$baseUrl}/chat.postMessage";
|
||||||
$channel = $notifiable->routeNotificationFor("slack", $notification);
|
$channel = $notifiable->routeNotificationFor("slack", $notification);
|
||||||
|
|
||||||
$message = $notification->toSlack($notifiable);
|
$message = $notification->toSlack($notifiable);
|
||||||
|
|
||||||
return Http::withToken($this->getClientToken())
|
Http::withToken($this->getClientToken())
|
||||||
->post($url, array_merge($message->getPayload(), [
|
->post($url, array_merge($message->getPayload(), [
|
||||||
"channel" => $channel,
|
"channel" => $channel,
|
||||||
]));
|
]));
|
||||||
|
@ -4,11 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
"google" => [
|
"google" => [
|
||||||
|
"calendar_enabled" => env("GOOGLE_CALENDAR_ENABLED", true),
|
||||||
"client_id" => env("GOOGLE_CLIENT_ID"),
|
"client_id" => env("GOOGLE_CLIENT_ID"),
|
||||||
"client_secret" => env("GOOGLE_CLIENT_SECRET"),
|
"client_secret" => env("GOOGLE_CLIENT_SECRET"),
|
||||||
"redirect" => env("GOOGLE_REDIRECT"),
|
"redirect" => env("GOOGLE_REDIRECT"),
|
||||||
],
|
],
|
||||||
"slack" => [
|
"slack" => [
|
||||||
|
"enabled" => env("SLACK_ENABLED", true),
|
||||||
"url" => "https://slack.com/api",
|
"url" => "https://slack.com/api",
|
||||||
"client_token" => env("SLACK_CLIENT_TOKEN"),
|
"client_token" => env("SLACK_CLIENT_TOKEN"),
|
||||||
"default_channel" => env("SLACK_DEFAULT_CHANNEL"),
|
"default_channel" => env("SLACK_DEFAULT_CHANNEL"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user