dunglas / mercure

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications
https://mercure.rocks
GNU Affero General Public License v3.0
3.98k stars 296 forks source link

Target deleted since v10.0 - How does it work now ? #341

Closed NUMERICKS closed 4 years ago

NUMERICKS commented 4 years ago

Hi,

It looks like targets have been removed since v10.0

So I was doing something like the following code with symfony/mercure

$update = new Update(
    "/chat_rooms/{room_id}",
    $jsonEncodedMessage,
    [/users/{id}]
);

$this->bus->dispatch($update);

So my users received the event cause they subscribe to /users/{id} through mercureAuthorization Since then it does not work anymore.

What would be a proper solution to get the same result ? How target has been substituted ?

Thank you

dunglas commented 4 years ago

Hi, see the UPGRADE guide and the updated specification.

martijnhartlief commented 4 years ago

The upgrade guide shows no real alternative for the use-case where the subscribed targets are dynamic.

There is no way to define what "private" means when your application decides who can see what. Now you need to know before hand what topics you want to subscribe to and refresh the token for each change to the underlying data.

Additionally the wildcard selector becomes useless and dangerious if something becomes private, which used to be incredibly usefull if you didn't know what your topics were, as a client. Now everone with a wildcard target gets everything, always.

dennobaby commented 4 years ago

Same here. This is especially a big problem if you have hundred of thousands of entities which a user should only see if some condition is there. With targets we could easily differentiate but with this version things go bad.

BafS commented 4 years ago

Same feeling for me, for example with a simple chat system, how do you do if the user join or leave a private channel ? Before you could use the target like chan/$name but now do you need to regenerate a new token for each action ?

dunglas commented 4 years ago

No you don't: see the end of this paragraph for an example.

BafS commented 4 years ago

Thanks @dunglas

karser commented 3 years ago

Updated from Mercure v0.3 to v0.11, everything went well, thanks @dunglas ! Targets are replaced with topics, it's very similar mechanics: image