Page MenuHomePhabricator

D13784.id.diff
No OneTemporary

D13784.id.diff

diff --git a/lib/types/farcaster-types.js b/lib/types/farcaster-types.js
--- a/lib/types/farcaster-types.js
+++ b/lib/types/farcaster-types.js
@@ -84,3 +84,8 @@
+data: NeynarWebhookCastCreatedData,
...
};
+
+export type NeynarPostCastResponse = {
+ +success: boolean,
+ ...
+};
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
@@ -7,6 +7,7 @@
NeynarChannel,
NeynarUser,
NeynarCast,
+ NeynarPostCastResponse,
} from '../types/farcaster-types.js';
type FetchRelevantFollowersResponse = {
@@ -357,6 +358,40 @@
throw error;
}
}
+
+ async postCast(
+ signerUUID: string,
+ parent: string,
+ text: string,
+ ): Promise<NeynarPostCastResponse> {
+ const url = getNeynarURL('2', 'cast', {});
+ const body = {
+ signer_uuid: signerUUID,
+ parent,
+ text,
+ };
+ try {
+ const response = await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Accept': 'application/json',
+ 'api_key': this.apiKey,
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(body),
+ });
+
+ const json = await response.json();
+
+ return json;
+ } catch (error) {
+ console.log(
+ 'Failed to post Farcaster cast:',
+ getMessageForException(error) ?? 'unknown',
+ );
+ throw error;
+ }
+ }
}
export { NeynarClient };

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 25, 3:33 AM (15 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2362185
Default Alt Text
D13784.id.diff (1 KB)

Event Timeline