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

fix: tags in subscriptions #56

Merged
merged 6 commits into from
May 28, 2024
Merged

fix: tags in subscriptions #56

merged 6 commits into from
May 28, 2024

Conversation

im-adithya
Copy link
Member

@im-adithya im-adithya commented May 17, 2024

Previously we didn't support tags (mistakenly), this fix makes sure tags can be passed alongside the other filter attributes like this

{
  "ids": ["id1", "id2"],
  "kinds": [1,2],
  "authors": ["author1", "author2"],
  "since": 1721212121,
  "until": 1721212121,
  "limit": 10,
  "search": "example search",
  "#p": ["g3ta16yxxxxxxx"],
  "#e": ["g3ta16yxxxxxxx"]
}

@im-adithya
Copy link
Member Author

Add README

Comment on lines 160 to 162
Tags nostr.Tags `json:"tags,omitempty"`
Since *nostr.Timestamp `json:"since,omitempty"`
Until *nostr.Timestamp `json:"until,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use the nostr lib types there or our own types that we then pack into a nostr Filter?

Copy link
Member Author

@im-adithya im-adithya May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ig it's best to use our own to keep it consistent 👍

It adds more code not only for the types (for example nostr.Timestamp has methods too) but also requires type conversion for Tags each time we use it in the library methods:

cannot use *subscription.Tags (variable of type TagMap) as "github.com/nbd-wtf/go-nostr".TagMap value in assignment

Best to use nostr lib types for now ig

@rolznz
Copy link

rolznz commented May 25, 2024

@im-adithya you have this "ADD README" comment. Can you update the filters in the readme or maybe even a full example with all the fields to be clear or add some examples? is this right for example? (Can you also update the guide?)

{
    "relayUrl":"wss://relay.getalby.com/v1",
    "webhookUrl": "https://webhook.site/4adc457f-c1d1-4324-974c-0187d0f02872",
    "filter": {
        "kinds": [ 23196 ],
        "authors": [
            "c8986738660e5e5ee92e21a51e1f2e5915ad7ee9e972f301fc670f8eb47e9bed"
        ],
        "tags": [[
            "p",
            "8d5dcdf26d765ee1b4c279f01aefe337d1eb76cec93e7d276f9fa5b803079c43"
        ]]
    }
}

@bumi
Copy link
Contributor

bumi commented May 27, 2024

update the readme as mentioned above and we merge this.

@im-adithya
Copy link
Member Author

Done, should be ready to merge!

@bumi
Copy link
Contributor

bumi commented May 27, 2024

so nothing changed?

@rolznz
Copy link

rolznz commented May 28, 2024

@im-adithya how does this work now? did you even test it?

@im-adithya
Copy link
Member Author

Lol yes, nothing has to be changed. Just the way tags are supplied is changed (hence those big README changes). The easyjson internally handles passing the tags like this:

{
  "#p": ["g3ta16yxxxxxxx"],
  "#e": ["g3ta16yxxxxxxx"]
}

Checked everything and works fine! The tags get stored properly in the subscriptions table too.

@bumi bumi merged commit 57fb1fa into main May 28, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants