Skip to content

Get badges with empty d tag using alternate method#4

Open
heguro wants to merge 4 commits intoverbiricha:masterfrom
heguro:patch-2
Open

Get badges with empty d tag using alternate method#4
heguro wants to merge 4 commits intoverbiricha:masterfrom
heguro:patch-2

Conversation

@heguro
Copy link
Contributor

@heguro heguro commented Mar 10, 2023

  • Added some code to get badges with empty d tag using alternate method
  • Disabled REQ with empty array filter. some relay (e.g.brb.io) returns anything when used filter like this.

I understand that this is an extreme edge case, but a few do exist.

@heguro heguro force-pushed the patch-2 branch 2 times, most recently from a7e11f7 to d125807 Compare March 10, 2023 12:44
@verbiricha
Copy link
Owner

Hey @heguro thanks a lot. I recently did some changes to the badges suscription code and moved it to useBadges so this PR needs updating. Will merge after is updated, lgtm.

@heguro
Copy link
Contributor Author

heguro commented Mar 13, 2023

Thanks for replying @verbiricha! I updated, and also covered things that I missed.
Last commit is added because I just like it, feel free to revert or ask me to remove.

@verbiricha
Copy link
Owner

Hey @heguro sorry for the delay reviewing this, looks good but found a small bug. Now that we are passing the full event instead of just id we need to update Badges.js or badge acceptance will no longer work, this should work:

--- a/src/lib/Badges.js
+++ b/src/lib/Badges.js
@@ -59,10 +59,10 @@ function Awarded({ awarded, accepted, pubkey }) {
     <Flex flexDirection="column" className="badge-list">
       {awarded.map(({ badge, award }) => {
         const d = findTag(badge.tags, "d");
-        const atag = `${badge.kind}:${badge.pubkey}:${d}`;
+        const atag = `${badge.kind}:${badge.pubkey}:${d ? d : ""}`;
         const accept = [
           ["a", atag],
-          ["e", award],
+          ["e", award.id],
         ];
         async function acceptBadge() {
           const ev = {

@heguro
Copy link
Contributor Author

heguro commented Mar 28, 2023

@verbiricha Updated. Thank you for finding it I missed.

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.

2 participants