Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger a single event on multiple encrypted channels #334

Closed
andrew-bibby opened this issue Jun 10, 2022 · 3 comments
Closed

Trigger a single event on multiple encrypted channels #334

andrew-bibby opened this issue Jun 10, 2022 · 3 comments

Comments

@andrew-bibby
Copy link
Contributor

I am using Laravel to broadcast to multiple channels at once, and now want to use e2e. Previously I would trigger one event broadcast to many different channels in one job by returning an array of private channels.

Would you be willing to consider a PR to allow events to be triggered on multiple encrypted channels? I have read the rationale in the readme however could it be possible to check that the specified channels are not a mixture of encrypted/unencrypted channels and if so just throw an exception?

Something like:


  if ($has_encrypted_channel) {
    if (PusherCrypto::has_mixed_channels($channels)) {
        throw new PusherException('You cannot trigger to multiple channels of different encryption type');
    } else {
        try {
            $data_encoded = $this->crypto->encrypt_payload(
                $channels[0],
                $already_encoded ? $data : json_encode($data, JSON_THROW_ON_ERROR)
            );
        } catch (\JsonException $e) {
            throw new PusherException('Data encoding error.');
        }
    }
} else {
    try {
        $data_encoded = $already_encoded ? $data : json_encode($data, JSON_THROW_ON_ERROR);
    } catch (\JsonException $e) {
        throw new PusherException('Data encoding error.');
    }
}

Alternatively it could be handled when validating the channels and throw in a different location?

Thanks. 👍

@benjamin-tang-pusher
Copy link
Contributor

Hi, have you tested this in your own application, and is it able to trigger to multiple encrypted channels?

@andrew-bibby
Copy link
Contributor Author

Yes I have created PR #337

@benjamin-tang-pusher
Copy link
Contributor

#337 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants