@@ -200,25 +200,18 @@ export const updateUserSocials = mutation({
200200 * Internal mutation to update user profile with Neynar data
201201 * This is specifically for syncing user information from Farcaster/Neynar
202202 */
203- export const updateUserProfileInternal = internalMutation ( {
203+ export const updateUserProfileInternalWithFarcaster = internalMutation ( {
204204 args : {
205205 userId : v . id ( 'users' ) ,
206+ fid : v . number ( ) ,
206207 bio : v . optional ( v . string ( ) ) ,
207208 displayName : v . optional ( v . string ( ) ) ,
208209 username : v . optional ( v . string ( ) ) ,
209210 pfpUrl : v . optional ( v . string ( ) ) ,
211+ linkedAccountId : v . id ( 'linkedAccounts' ) ,
210212 } ,
211213 handler : async ( ctx , args ) => {
212- const { userId, ...updateFields } = args ;
213-
214- // Check if user exists
215- const existingUser = await ctx . db . get ( userId ) ;
216- if ( ! existingUser ) {
217- throw new ConvexError ( {
218- message : 'User not found' ,
219- code : 'USER_NOT_FOUND' ,
220- } ) ;
221- }
214+ const { userId, linkedAccountId, ...updateFields } = args ;
222215
223216 // Filter out undefined values to avoid removing fields unintentionally
224217 const fieldsToUpdate = Object . fromEntries (
@@ -231,6 +224,14 @@ export const updateUserProfileInternal = internalMutation({
231224 return ;
232225 }
233226
227+ await ctx . db . patch ( linkedAccountId , {
228+ account : {
229+ protocol : 'farcaster' ,
230+ fid : args . fid ,
231+ ...fieldsToUpdate ,
232+ lastSyncedAt : Date . now ( ) ,
233+ } ,
234+ } ) ;
234235 await ctx . db . patch ( userId , fieldsToUpdate ) ;
235236 } ,
236237} ) ;
0 commit comments