Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3327097
D13980.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13980.id.diff
View Options
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
@@ -21,13 +21,18 @@
...
};
-type FetchFarcasterChannelsResponse = {
+type FetchFarcasterChannelsPagedResponse = {
+channels: $ReadOnlyArray<NeynarChannel>,
+next: {
+cursor: ?string,
},
};
+type FetchFarcasterChannelsResponse = {
+ +channels: $ReadOnlyArray<NeynarChannel>,
+ ...
+};
+
type FetchUsersResponse = {
+users: $ReadOnlyArray<NeynarUser>,
};
@@ -128,7 +133,7 @@
},
});
- const json: FetchFarcasterChannelsResponse = await response.json();
+ const json: FetchFarcasterChannelsPagedResponse = await response.json();
const { channels, next } = json;
@@ -177,6 +182,36 @@
}
}
+ async fetchFarcasterChannelsByIDs(
+ channelIDs: $ReadOnlyArray<string>,
+ ): Promise<NeynarChannel[]> {
+ const params: { [string]: string } = {
+ ids: channelIDs.join(','),
+ };
+
+ const url = getNeynarURL('2', 'channel/bulk', params);
+
+ try {
+ const response = await fetch(url, {
+ method: 'GET',
+ headers: {
+ Accept: 'application/json',
+ api_key: this.apiKey,
+ },
+ });
+
+ const json: FetchFarcasterChannelsResponse = await response.json();
+
+ return json.channels ? [...json.channels] : [];
+ } catch (error) {
+ console.log(
+ 'Failed to fetch Farcaster channel infos:',
+ getMessageForException(error) ?? 'unknown',
+ );
+ throw error;
+ }
+ }
+
async getFarcasterUsers(
fids: $ReadOnlyArray<string>,
): Promise<Array<?FarcasterUser>> {
@@ -243,7 +278,7 @@
},
});
- const json: FetchFarcasterChannelsResponse = await response.json();
+ const json: FetchFarcasterChannelsPagedResponse = await response.json();
const { channels, next } = json;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 8:17 AM (7 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555278
Default Alt Text
D13980.id.diff (1 KB)
Attached To
Mode
D13980: [lib] Introduce NeynarClient.fetchFarcasterChannelsByIDs
Attached
Detach File
Event Timeline
Log In to Comment