Page MenuHomePhabricator

[lib] introduce fetchFarcasterChannelByName to neynar client class
ClosedPublic

Authored by ginsu on May 3 2024, 12:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 12, 3:40 PM
Unknown Object (File)
Sun, May 12, 10:09 AM
Unknown Object (File)
Sun, May 12, 7:50 AM
Unknown Object (File)
Sat, May 11, 10:37 PM
Unknown Object (File)
Fri, May 10, 1:00 PM
Unknown Object (File)
Fri, May 10, 12:39 PM
Unknown Object (File)
Thu, May 9, 3:34 PM
Unknown Object (File)
Wed, May 8, 11:43 AM
Subscribers

Details

Summary

fetchFarcasterChannelByName is a function that given a farcaster channel name, will retreive the info for that channel. The reason for this function is that we want to validate the user input given to us from the TagUnfollowedFarcasterChannel screen and confirm that the user inputted a valid channel name.

If the user inputted a channel name that does not exist, fetchFarcasterChannelByName will return null

Neynar API docs: https://docs.neynar.com/reference/search-channels

Linear task: https://linear.app/comm/issue/ENG-7471/add-the-search-channels-neynar-endpoint-to-our-neynar-api-client

Test Plan

Used the neynar docs to confirm that fetchFarcasterChannelByName was getting the expected/same response as the docs.

Additionally confirmed that fetchFarcasterChannelByName when I inputted a channel name that does not exist on farcaster

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu added reviewers: ashoat, inka.
ginsu edited the summary of this revision. (Show Details)
ginsu edited the summary of this revision. (Show Details)
Harbormaster returned this revision to the author for changes because remote builds failed.May 3 2024, 12:48 AM
Harbormaster failed remote builds in B28640: Diff 39758!
ginsu requested review of this revision.May 3 2024, 12:50 AM

will make sure ci passes before landing

ashoat added inline comments.
lib/utils/neynar-client.js
28 ↗(On Diff #39758)

Surprised there are no other properties here… sure we don’t need a ?

155 ↗(On Diff #39758)

Is Neynar’s API case-insensitive? Wondering since you have toLowerCase below

This revision is now accepted and ready to land.Sat, May 4, 11:03 AM
lib/utils/neynar-client.js
28 ↗(On Diff #39758)

The response only has channels. Here is an example:

{
  "channels": [
    {
      "id": "neynar",
      "url": "chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc",
      "name": "Neynar",
      "description": "The easiest way to build on Farcaster | neynar.com | @neynar",
      "follower_count": 7680,
      "object": "channel",
      "image_url": "https://i.imgur.com/j9CEVlk.png",
      "created_at": 1690488765,
      "parent_url": "chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc",
      "lead": {
        "object": "user",
        "fid": 194,
        "custody_address": "0xb95dc10483be18f7c69ddf78d4baafecc01c5530",
        "username": "rish",
        "display_name": "rish",
        "pfp_url": "https://i.imgur.com/naZWL9n.gif",
        "profile": {
          "bio": {
            "text": "building /neynar 🪐 | neynar.com | /rish "
          }
        },
        "follower_count": 110419,
        "following_count": 665,
        "verifications": [
          "0x5a927ac639636e534b678e81768ca19e2c6280b7",
          "0xe9e261852ea62150eee685807df8fe3f211310a0"
        ],
        "verified_addresses": {
          "eth_addresses": [
            "0x5a927ac639636e534b678e81768ca19e2c6280b7",
            "0xe9e261852ea62150eee685807df8fe3f211310a0"
          ],
          "sol_addresses": []
        },
        "active_status": "inactive",
        "power_badge": true,
        "notes": {
          "active_status": "Warpcast has transitioned from active badges to power badges, Neynar will deprecate this key in the user object in the next few weeks"
        }
      },
      "hosts": [
        {
          "object": "user",
          "fid": 194,
          "custody_address": "0xb95dc10483be18f7c69ddf78d4baafecc01c5530",
          "username": "rish",
          "display_name": "rish",
          "pfp_url": "https://i.imgur.com/naZWL9n.gif",
          "profile": {
            "bio": {
              "text": "building /neynar 🪐 | neynar.com | /rish "
            }
          },
          "follower_count": 110419,
          "following_count": 665,
          "verifications": [
            "0x5a927ac639636e534b678e81768ca19e2c6280b7",
            "0xe9e261852ea62150eee685807df8fe3f211310a0"
          ],
          "verified_addresses": {
            "eth_addresses": [
              "0x5a927ac639636e534b678e81768ca19e2c6280b7",
              "0xe9e261852ea62150eee685807df8fe3f211310a0"
            ],
            "sol_addresses": []
          },
          "active_status": "inactive",
          "power_badge": true,
          "notes": {
            "active_status": "Warpcast has transitioned from active badges to power badges, Neynar will deprecate this key in the user object in the next few weeks"
          }
        },
        {
          "object": "user",
          "fid": 191,
          "custody_address": "0x3a6dd569de84c91828fc42dce20f5b827e0ef5c5",
          "username": "manan",
          "display_name": "Manan ",
          "pfp_url": "https://i.imgur.com/nW6pvvm.jpg",
          "profile": {
            "bio": {
              "text": "🪐 Building @neynar, join us in /neynar | ex-Coinbase | manan19.twitter"
            }
          },
          "follower_count": 108602,
          "following_count": 376,
          "verifications": [
            "0x7cac817861e5c3384753403fb6c0c556c204b1ce"
          ],
          "verified_addresses": {
            "eth_addresses": [
              "0x7cac817861e5c3384753403fb6c0c556c204b1ce"
            ],
            "sol_addresses": [
              "GyBd7Ukpd3LJnjDkBG8wioRaCKQFURfDhLRnSc6EgrPi"
            ]
          },
          "active_status": "inactive",
          "power_badge": true,
          "notes": {
            "active_status": "Warpcast has transitioned from active badges to power badges, Neynar will deprecate this key in the user object in the next few weeks"
          }
        },
        {
          "object": "user",
          "fid": 6131,
          "custody_address": "0xa6a8736f18f383f1cc2d938576933e5ea7df01a1",
          "username": "neynar",
          "display_name": "Neynar",
          "pfp_url": "https://i.imgur.com/UjBZ3pV.png",
          "profile": {
            "bio": {
              "text": "best farcaster developers build on neynar.com | /neynar"
            }
          },
          "follower_count": 3876,
          "following_count": 47,
          "verifications": [
            "0xa6a8736f18f383f1cc2d938576933e5ea7df01a1"
          ],
          "verified_addresses": {
            "eth_addresses": [
              "0xa6a8736f18f383f1cc2d938576933e5ea7df01a1"
            ],
            "sol_addresses": []
          },
          "active_status": "inactive",
          "power_badge": true,
          "notes": {
            "active_status": "Warpcast has transitioned from active badges to power badges, Neynar will deprecate this key in the user object in the next few weeks"
          }
        }
      ]
    }
  ]
}
155 ↗(On Diff #39758)

Yes confirmed that Neynar's API is case-insensitive

Screenshot 2024-05-05 at 8.31.03 PM.png (868×2 px, 241 KB)

Removing this diff from the diff stack so that I can land as is.

ginsu edited the summary of this revision. (Show Details)

rebase before landing