diff --git a/lib/utils/neynar-client.js b/lib/utils/neynar-client.js --- a/lib/utils/neynar-client.js +++ b/lib/utils/neynar-client.js @@ -151,10 +151,10 @@ async fetchFarcasterChannelByID(channelID: string): Promise { const params: { [string]: string } = { - q: channelID, + id: channelID, }; - const url = getNeynarURL('2', 'channel/search', params); + const url = getNeynarURL('2', 'channel', params); try { const response = await fetch(url, { @@ -165,19 +165,12 @@ }, }); - const json: FetchFarcasterChannelsResponse = await response.json(); - const { channels } = json; - - for (const channel of channels) { - if (channel.id.toLowerCase() === channelID.toLowerCase()) { - return channel; - } - } + const json: FetchFarcasterChannelInfoResponse = await response.json(); - return null; + return json.channel; } catch (error) { console.log( - `Failed to search Farcaster channel by ID:`, + 'Failed to fetch Farcaster channel info:', getMessageForException(error) ?? 'unknown', ); throw error; @@ -271,39 +264,6 @@ return farcasterChannels; } - async fetchFarcasterChannelInfo( - channelID: string, - viewerFID: string, - ): Promise { - const params: { [string]: string } = { - id: channelID, - type: 'id', - viewer_fid: viewerFID, - }; - - const url = getNeynarURL('2', 'channel', params); - - try { - const response = await fetch(url, { - method: 'GET', - headers: { - Accept: 'application/json', - api_key: this.apiKey, - }, - }); - - const json: FetchFarcasterChannelInfoResponse = await response.json(); - - return json.channel; - } catch (error) { - console.log( - 'Failed to fetch Farcaster channel info:', - getMessageForException(error) ?? 'unknown', - ); - throw error; - } - } - async checkIfCurrentUserFIDIsValid(fid: string): Promise { const url = getNeynarURL('2', 'user/bulk', { fids: fid });