Skip to content

Commit df66e63

Browse files
committed
Patch: New embedded comments make notifications
1 parent a20018a commit df66e63

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ public function store(Request $request)
10731073
}
10741074

10751075
// Embedded Comments
1076-
$a_result_errors = $this->add_embedded_comments($request, $ticket, $a_result_errors);
1076+
list($a_new_comments, $a_result_errors) = $this->add_embedded_comments($request, $ticket, $a_result_errors);
10771077

10781078
// If errors present
10791079
if ($a_result_errors){
@@ -1090,7 +1090,7 @@ public function store(Request $request)
10901090
event(new TicketCreated($ticket));
10911091

10921092
// Comment events
1093-
if (isset($a_new_comments) and $a_new_comments){
1093+
if ($a_new_comments){
10941094
foreach($a_new_comments as $comment){
10951095
event(new CommentCreated(Models\Comment::find($comment->id), $request));
10961096
}
@@ -1115,6 +1115,8 @@ public function store(Request $request)
11151115
*/
11161116
public function add_embedded_comments($request, $ticket, $a_result_errors)
11171117
{
1118+
$a_new_comments = [];
1119+
11181120
if ($request->has('form_comments')){
11191121
$custom_messages = [
11201122
'content.required' => trans('panichd::lang.validate-comment-required'),
@@ -1148,7 +1150,7 @@ public function add_embedded_comments($request, $ticket, $a_result_errors)
11481150
}
11491151
}
11501152

1151-
return $a_result_errors;
1153+
return [$a_new_comments, $a_result_errors];
11521154
}
11531155

11541156
public function downloadAttachment($attachment_id)
@@ -1340,7 +1342,7 @@ public function update(Request $request, $id)
13401342
}
13411343

13421344
// Embedded Comments
1343-
$a_result_errors = $this->add_embedded_comments($request, $ticket, $a_result_errors);
1345+
list($a_new_comments, $a_result_errors) = $this->add_embedded_comments($request, $ticket, $a_result_errors);
13441346

13451347
// If errors present
13461348
if ($a_result_errors){
@@ -1359,6 +1361,13 @@ public function update(Request $request, $id)
13591361
DB::commit();
13601362
event(new TicketUpdated($original_ticket, $ticket));
13611363

1364+
// Comment events
1365+
if ($a_new_comments){
1366+
foreach($a_new_comments as $comment){
1367+
event(new CommentCreated(Models\Comment::find($comment->id), $request));
1368+
}
1369+
}
1370+
13621371
// Add complete/reopen comment
13631372
if ($original_ticket->completed_at != $ticket->completed_at and ($original_ticket->completed_at == '' or $ticket->completed_at == '') ){
13641373
$this->complete_change_actions($ticket, $member);

0 commit comments

Comments
 (0)