#116 - integration with slack (#129)

* wip

* wip

* wip

* wip

* fix

* wip

* wip

* fix

* fix

* cs fix

* #116 - fix

* #116 - changed home-office icon

* Apply suggestions from code review

Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>

* #116 - cr fix

* #116 - cs fix

* #116 - cs fix

* Apply suggestions from code review

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* #5 - bump codestyle

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>
Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
Adrian Hopek
2022-04-27 09:57:13 +02:00
committed by GitHub
parent d60dc75f99
commit c69866bb52
78 changed files with 1597 additions and 243 deletions

View File

@@ -22,7 +22,17 @@ class VacationRequestStatusChangedNotification extends Notification
public function via(): array
{
return ["mail"];
return [Channels::MAIL, Channels::SLACK];
}
public function toSlack(): string
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
return implode("\n", [
$this->buildDescription(),
"<${url}|Zobacz szczegóły>",
]);
}
/**
@@ -43,27 +53,17 @@ class VacationRequestStatusChangedNotification extends Notification
protected function buildMailMessage(string $url): MailMessage
{
$user = $this->user->profile->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$status = $this->vacationRequest->state->label();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->profile->full_name;
return (new MailMessage())
->greeting(__("Hi :user!", [
"user" => $user,
]))
->subject(__("Vacation request :title has been :status", [
"title" => $title,
"status" => $status,
]))
->line(__("The vacation request :title from user :requester has been :status.", [
"title" => $title,
"requester" => $requester,
"status" => $status,
]))
->subject($this->buildSubject())
->line($this->buildDescription())
->line(__("Vacation type: :type", [
"type" => $type,
]))
@@ -74,4 +74,21 @@ class VacationRequestStatusChangedNotification extends Notification
]))
->action(__("Click here for details"), $url);
}
protected function buildSubject(): string
{
return __("Vacation request :title has been :status", [
"title" => $this->vacationRequest->name,
"status" => $this->vacationRequest->state->label(),
]);
}
protected function buildDescription(): string
{
return __("The vacation request :title from user :requester has been :status.", [
"title" => $this->vacationRequest->name,
"requester" => $this->vacationRequest->user->profile->full_name,
"status" => $this->vacationRequest->state->label(),
]);
}
}