- Triggers (Admin > Wyzwalacze): event-driven rules that fire immediately on a ticket lifecycle event (created/updated/status/priority/assignee/team/ category changed, new reply), with AND-conditions and ordered actions (set status/priority/team/assignee, send e-mail). Ships its own dedicated, freely add/edit/delete-able e-mail templates, kept separate from the fixed system templates. - Ticket watching: operators can star/"Obserwuj" any ticket to follow it regardless of assignment/team. - Real-time notification bell (private per-user broadcast channel, 30s fallback poll) with an opt-in in-tab browser push notification. - Per-user notification preferences (/settings/notifications): scope (mine/unassigned/watched/all) and e-mail toggle per event category. - Admin > Integracje: new tab for LDAP/AD + BookStack config, split out of Konfiguracja. - Operator queue: Podkategoria/Zespół/Utworzono columns (off by default). - Obserwuj button moved next to the auto-refresh countdown; trigger condition builder shows subcategory/zgłaszający as name dropdowns instead of raw IDs; /settings/notifications got a back link, full-width push card, and a bordered table container; admin panel tab and operator queue view now persist across a plain page refresh. - Docs: README/ARCHITECTURE/wiki updated for all of the above. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.8 KiB
PHP
48 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Models\Ticket;
|
|
use Illuminate\Support\Facades\Broadcast;
|
|
|
|
/**
|
|
* One shared channel for anything queue-relevant (new/changed/closed
|
|
* tickets) rather than per-team channels — payloads carry only minimal
|
|
* metadata, so the receiving Livewire component just re-queries through its
|
|
* own already-correct Ticket::scopeVisibleToOperator() instead of this
|
|
* callback needing to duplicate that ACL logic.
|
|
*/
|
|
Broadcast::channel('operator.queue', function ($user) {
|
|
return in_array('operator', $user->roles ?? []) || $user->isAdmin();
|
|
});
|
|
|
|
/**
|
|
* Per-ticket channel for message/detail changes (drives both the live
|
|
* message thread and live ticket-header updates). OR, not else-if — the
|
|
* owner's account holds both client and operator roles at once, so both
|
|
* branches must be checked rather than picking one based on role alone.
|
|
* Payloads here also stay minimal (never the message body itself), so an
|
|
* internal note can safely broadcast on the same channel a client is
|
|
* subscribed to — the client's own computed properties never touch
|
|
* internal messages regardless of which event arrived.
|
|
*/
|
|
Broadcast::channel('ticket.{ticketId}', function ($user, int $ticketId) {
|
|
$ticket = Ticket::query()->find($ticketId);
|
|
|
|
if (! $ticket) {
|
|
return false;
|
|
}
|
|
|
|
return (in_array('operator', $user->roles ?? []) && $ticket->isVisibleToOperator($user))
|
|
|| $ticket->customer_id === $user->id;
|
|
});
|
|
|
|
/**
|
|
* Every logged-in user's own private notification stream (bell realtime
|
|
* updates + in-tab browser push, see NotificationCreated). Laravel's
|
|
* default `App.Models.User.{id}` naming convention is kept verbatim so it
|
|
* matches what `$notifiable->notify()` already implies, rather than
|
|
* inventing a shorter alias.
|
|
*/
|
|
Broadcast::channel('App.Models.User.{id}', function ($user, int $id) {
|
|
return $user->id === $id;
|
|
});
|