diff --git a/lib/shared/farcaster/farcaster-api.js b/lib/shared/farcaster/farcaster-api.js --- a/lib/shared/farcaster/farcaster-api.js +++ b/lib/shared/farcaster/farcaster-api.js @@ -453,6 +453,42 @@ ); } +export type UpdateFarcasterGroupPhotoInput = { + +conversationId: string, + +photoUrl: string, +}; + +function useUpdateFarcasterGroupPhoto(): ( + input: UpdateFarcasterGroupPhotoInput, +) => Promise { + const { sendFarcasterRequest } = useTunnelbroker(); + const { addLog } = useDebugLogs(); + return React.useCallback( + async (input: UpdateFarcasterGroupPhotoInput) => { + try { + await sendFarcasterRequest({ + apiVersion: 'v2', + endpoint: 'direct-cast-group-photo', + method: { type: 'POST' }, + payload: JSON.stringify(input), + }); + } catch (error) { + addLog( + 'Farcaster API: Failed to update group photo', + JSON.stringify({ + conversationId: input.conversationId, + photoUrl: input.photoUrl, + error: getMessageForException(error), + }), + new Set([logTypes.FARCASTER, logTypes.ERROR]), + ); + throw error; + } + }, + [addLog, sendFarcasterRequest], + ); +} + export type UpdateFarcasterSubscriptionInput = { +conversationId: string, +muted: boolean, @@ -971,6 +1007,7 @@ useFetchFarcasterConversation, useFetchFarcasterInbox, useUpdateFarcasterGroupNameAndDescription, + useUpdateFarcasterGroupPhoto, useUpdateFarcasterSubscription, useStreamFarcasterDirectCastRead, useMarkFarcasterDirectCastUnread,