# fluent-support/2.4.0/app/Services/Notifications/RecipientResolver.php

Fluent Support – Helpdesk &amp; Customer Support Ticket System, version 2.4.0. 82 lines.

- Page: https://pluginprobe.com/plugins/fluent-support/2.4.0/code/app/Services/Notifications/RecipientResolver.php
- Raw: https://pluginprobe.com/plugins/fluent-support/2.4.0/raw/app/Services/Notifications/RecipientResolver.php
- Modified: 2026-05-20T14:52:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-support/2.4.0/code/app/Services/Notifications/RecipientResolver.php#L10-L20`.

```php
<?php

namespace FluentSupport\App\Services\Notifications;

use FluentSupport\App\Models\Agent;
use FluentSupport\App\Models\Ticket;

class RecipientResolver
{
    /**
     * @param array $agentIds
     * @param int|null $excludePersonId
     * @return \FluentSupport\Framework\Support\Collection
     */
    public function resolveMentionedAgents(array $agentIds, $excludePersonId = null)
    {
        $agentIds = array_values(array_unique(array_filter(array_map('intval', $agentIds))));

        if (!$agentIds) {
            return Agent::whereIn('id', [0])->get();
        }

        $query = Agent::whereIn('id', $agentIds);

        if ($excludePersonId) {
            $query->where('id', '!=', (int) $excludePersonId);
        }

        return $query->get();
    }

    /**
     * Resolve a ticket's assigned agent, optionally excluding the actor.
     *
     * @param \FluentSupport\App\Models\Ticket $ticket
     * @param int|null $excludePersonId
     * @return \FluentSupport\App\Models\Agent|null
     */
    public function resolveAssignedAgent(Ticket $ticket, $excludePersonId = null)
    {
        if (!$ticket->agent_id) {
            return null;
        }

        $query = Agent::where('id', $ticket->agent_id);

        if ($excludePersonId) {
            $query->where('id', '!=', $excludePersonId);
        }

        return $query->first();
    }

    /**
     * Normalize recipient person IDs for notification fanout.
     *
     * @param iterable $recipients
     * @param int|null $excludePersonId
     * @return array
     */
    public function extractRecipientPersonIds($recipients, $excludePersonId = null)
    {
        $ids = [];

        foreach ($recipients as $recipient) {
            if (!$recipient || empty($recipient->id)) {
                continue;
            }

            $recipientId = (int) $recipient->id;

            if ($excludePersonId && $recipientId === (int) $excludePersonId) {
                continue;
            }

            $ids[] = $recipientId;
        }

        return array_values(array_unique($ids));
    }
}

```
