Skip to content

Commit

Permalink
feat: add new end notification (#56)
Browse files Browse the repository at this point in the history
separate edited and closed operation notifications to their own.
  • Loading branch information
veteranmina authored and warlof committed Dec 28, 2021
1 parent e0d57ff commit 0cfba64
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Notifications/OperationEnded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Seat\Kassie\Calendar\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\SlackMessage;
use Seat\Kassie\Calendar\Helpers\Helper;

/**
* Class OperationEnded.
*
* @package Seat\Kassie\Calendar\Notifications
*/
class OperationEnded extends Notification
{
use Queueable;

/**
* @param $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}

/**
* @param $notifiable
* @return mixed
*/
public function toSlack($notifiable)
{
$attachment = Helper::BuildSlackNotificationAttachment($notifiable);

return (new SlackMessage)
->success()
->from('SeAT Calendar', ':calendar:')
->content(trans('calendar::seat.notification_end_operation'))
->attachment($attachment);
}
}
4 changes: 4 additions & 0 deletions src/Observers/OperationObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Seat\Kassie\Calendar\Notifications\OperationUpdated;
use Seat\Kassie\Calendar\Notifications\OperationCancelled;
use Seat\Kassie\Calendar\Notifications\OperationActivated;
use Seat\Kassie\Calendar\Notifications\OperationEnded;

/**
* Class OperationObserver.
Expand Down Expand Up @@ -38,6 +39,9 @@ public function updating(Operation $new_operation)
else
Notification::send($new_operation, new OperationActivated());
}
elseif ($old_operation->end_at != $new_operation->end_at && $new_operation->is_cancelled == false) {
Notification::send($new_operation, new OperationEnded());
}
else {
Notification::send($new_operation, new OperationUpdated());
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/lang/en/seat.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
'notification_cancel_operation' => '<!channel> :no_entry_sign: An operation has been cancelled !',
'notification_activate_operation' => '<!channel> :white_check_mark: A cancelled operation has been reactivated !',
'notification_ping_operation' => '<!channel> :bell: ',
'notification_end_operation' => '<!here> :no_entry_sign: This operation has ended!',
'notification_enable' => 'Notify to Slack',
'integration_channel' => 'Integration Channel',

Expand Down
1 change: 1 addition & 0 deletions src/resources/lang/zh-CN/seat.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'notification_edit_operation' => '<!channel> :pencil2: 一个行动被编辑了!',
'notification_cancel_operation' => '<!channel> :no_entry_sign: 一个行动被取消!',
'notification_activate_operation' => '<!channel> :white_check_mark: 一个已取消的行动被重新激活了!',
'notification_end_operation' => '<!here> :no_entry_sign: 此操作已结束!',
'notification_ping_operation' => '<!channel> :bell: ',
'notification_enable' => '通知到 Slack',
'integration_channel' => '集成频道',
Expand Down

0 comments on commit 0cfba64

Please sign in to comment.