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

Filtering subscriptions by topic doesn't work #833

Open
itodor opened this issue Nov 15, 2023 · 1 comment
Open

Filtering subscriptions by topic doesn't work #833

itodor opened this issue Nov 15, 2023 · 1 comment

Comments

@itodor
Copy link
Contributor

itodor commented Nov 15, 2023

I am trying to use as minimal example as possible, I just spinned out of the box docker-compose proposed file on my localhost from official link https://mercure.rocks/docs/hub/install (the only difference is I disabled HTTPS so i run on normal :80).

I made dummy client who connects to 3 topics just for testing purposes, all the same user payload, topics are named (1,2,3), I know they should be URI formatted but for testing purposes I wanted to simplify as much as possible. So when I do the following call it confirms that this client is listening on 3 topics:

➜  ~ curl 'http://localhost/.well-known/mercure/subscriptions' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdLCJzdWJzY3JpYmUiOlsiKiJdLCJwYXlsb2FkIjp7InVzZXIiOiIxMTExMTEifX19.09mOg1RCswaUDqdMOQ54FjZQqKtbFq1wgMxfD-5tA98'

I get:

{
  "@context": "https://mercure.rocks/",
  "id": "/.well-known/mercure/subscriptions",
  "type": "Subscriptions",
  "lastEventID": "urn:uuid:0ec53206-0d81-43b1-8f9f-e682963f27a5",
  "subscriptions": [
    {
      "id": "/.well-known/mercure/subscriptions/1/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "1",
      "active": true,
      "payload": {
        "user": "333333"
      }
    },
    {
      "id": "/.well-known/mercure/subscriptions/2/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "2",
      "active": true,
      "payload": {
        "user": "333333"
      }
    },
    {
      "id": "/.well-known/mercure/subscriptions/3/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "3",
      "active": true,
      "payload": {
        "user": "333333"
      }
    }
  ]
}%

Everything as expected, but now I want to filter by topics, so I just want it to show me subscriptions that are connected to the topic 2:

➜  ~ curl 'http://localhost/.well-known/mercure/subscriptions/2' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdLCJzdWJzY3JpYmUiOlsiKiJdLCJwYXlsb2FkIjp7InVzZXIiOiIxMTExMTEifX19.09mOg1RCswaUDqdMOQ54FjZQqKtbFq1wgMxfD-5tA98'

I get:

{
  "@context": "https://mercure.rocks/",
  "id": "/.well-known/mercure/subscriptions/2",
  "type": "Subscriptions",
  "lastEventID": "urn:uuid:0ec53206-0d81-43b1-8f9f-e682963f27a5",
  "subscriptions": [
    {
      "id": "/.well-known/mercure/subscriptions/1/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "1",
      "active": true,
      "payload": {
        "user": "333333"
      }
    },
    {
      "id": "/.well-known/mercure/subscriptions/2/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "2",
      "active": true,
      "payload": {
        "user": "333333"
      }
    },
    {
      "id": "/.well-known/mercure/subscriptions/3/urn%3Auuid%3Abf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "type": "Subscription",
      "subscriber": "urn:uuid:bf7ef475-b1b8-4f3e-a2ae-b89b94184465",
      "topic": "3",
      "active": true,
      "payload": {
        "user": "333333"
      }
    }
  ]
}%

I am still getting all 3 subscriptions even though I just want the 2nd one with topic 2.

Interestingly enough, its not that it doesn't work at all, for example, in examples before I was playing with 3 users, so when I would query for all the subscriptions, I would get obviously all subscriptions, but when I filtered for topic X, I would get only subscriptions that are connected to topic X BUT also I would get all their other subscriptions as well which I don't want.

Is this the way its supposed to work and I have to do filtering manually on my side or am I missing something?

@frizquierdo
Copy link

The issue it's reported here. With cookie authorization also happen.

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