Skip to content

Commit 120e229

Browse files
committed
Internal note update: Notify all users that where notified in note creation
1 parent 1e3b8de commit 120e229

2 files changed

Lines changed: 19 additions & 24 deletions

File tree

src/Controllers/NotificationsController.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -229,27 +229,21 @@ public function commentUpdate(Comment $original_comment, Comment $comment)
229229
'notification_owner' => serialize($notification_owner)
230230
];
231231

232-
$a_to=[];
233-
234-
// Email to ticket->agent
235-
if ($ticket->agent->email != $notification_owner->email){
236-
$a_to[] = [
237-
'recipient' => $ticket->agent,
238-
'subject' => $subject,
239-
'template' => $template
240-
];
241-
}
242-
243-
// Email to comment->owner
244-
if (!$ticket->hidden and !in_array($comment->owner->email, [$notification_owner->email, $ticket->agent->email])){
245-
$a_to[] = [
246-
'recipient' => $comment->owner,
247-
'subject' => $subject,
248-
'template' => $template
249-
];
250-
}
232+
// Send notification to all comment notified users
233+
foreach ($comment->notifications as $notification){
234+
$recipient = Member::find($notification->member_id);
235+
if (count($recipient) == 1){
236+
if ($recipient->email != $notification_owner->email){
237+
$a_to[] = [
238+
'recipient' => $recipient,
239+
'subject' => $subject,
240+
'template' => $template
241+
];
242+
}
243+
}
244+
}
251245

252-
$this->sendNotification($a_to, $data);
246+
if(isset($a_to)) $this->sendNotification($a_to, $data);
253247
}
254248
}
255249

src/Views/emails/updated_comment.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
$notification_owner = unserialize($notification_owner);
33
$comment = unserialize($comment);
44
$original_comment = unserialize($original_comment);
@@ -16,8 +16,9 @@
1616
@else
1717
<p>{!! trans('panichd::email/globals.updated_other_note', ['user' => $notification_owner->name, 'other' => $comment->owner->name]) !!}</p>
1818
@endif
19-
20-
@include('panichd::emails.partial.common_fields')
19+
@if ($recipient->levelInCategory($ticket->category->id) > 1)
20+
@include('panichd::emails.partial.common_fields')
21+
@endif
2122
<b>{{ trans('panichd::email/globals.original_note_title') }}</b>
2223
<table border="0" cellpadding="10" cellspacing="0" style="border: 1px solid #ddd; border-radius: 5px;"><tr>
2324
<td>@include('panichd::emails.partial.html_field', ['html_field' => $original_comment->html])</td>
@@ -26,5 +27,5 @@
2627
<table border="0" cellpadding="10" cellspacing="0" style="border: 1px solid #ddd; border-radius: 5px;"><tr>
2728
<td>@include('panichd::emails.partial.html_field', ['html_field' => $comment->html])</td>
2829
</tr></table><br /><br />
29-
30+
3031
@stop

0 commit comments

Comments
 (0)