<?php

declare(strict_types=1);

use App\Models\User;
use Illuminate\Support\Facades\Broadcast;

/*
| Private channels for real-time marketplace events -- an offer countered, a
| transfer advancing. Authorisation is per user: a channel name embedding a
| public id is not proof of ownership, so it is checked here.
*/

Broadcast::channel('users.{publicId}', function (User $user, string $publicId): bool {
    return hash_equals($user->public_id, $publicId);
});
