diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -942,13 +942,12 @@ return null; } - const ledChannels = - await neynarClient?.fetchLedFarcasterChannels(farcasterID); + const userLeadsChannel = await neynarClient?.userLeadsChannel( + farcasterID, + communityFarcasterChannelTag, + ); - if ( - !ledChannels || - !ledChannels.some(channel => channel.id === communityFarcasterChannelTag) - ) { + if (!userLeadsChannel) { return null; } 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 @@ -225,6 +225,21 @@ } } + userLeadsChannel(fid: string, channelName: string): Promise { + const userChannelsPromise = (async () => { + const ledChannels = await this.fetchLedFarcasterChannels(fid); + return ledChannels.some( + channel => channel.id === channelName && channel.lead.fid === fid, + ); + })(); + const channelSearchPromise = (async () => { + const channel = await this.fetchFarcasterChannelByName(channelName); + return channel?.lead.fid === fid; + })(); + + return Promise.race([userChannelsPromise, channelSearchPromise]); + } + async getFarcasterUsers( fids: $ReadOnlyArray, ): Promise> {