Page MenuHomePhabricator

D13980.id.diff
No OneTemporary

D13980.id.diff

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

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)

Event Timeline