A decentralized music tracking and discovery platform built on AT Protocol 🎵
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove unused deepSnakeCaseKeys import and restructure user payload logging

+15 -8
+15 -8
apps/api/src/scripts/avatar.ts
··· 1 1 import { ctx } from "context"; 2 2 import { eq, or } from "drizzle-orm"; 3 - import { deepSnakeCaseKeys } from "lib"; 4 3 import _ from "lodash"; 5 4 import users from "schema/users"; 6 5 ··· 19 18 } 20 19 21 20 const plc = await fetch(`https://plc.directory/${user.did}`).then((res) => 22 - res.json(), 21 + res.json() 23 22 ); 24 23 25 24 const serviceEndpoint = _.get(plc, "service.0.serviceEndpoint"); ··· 29 28 } 30 29 31 30 const profile = await fetch( 32 - `${serviceEndpoint}/xrpc/com.atproto.repo.getRecord?repo=${user.did}&collection=app.bsky.actor.profile&rkey=self`, 31 + `${serviceEndpoint}/xrpc/com.atproto.repo.getRecord?repo=${user.did}&collection=app.bsky.actor.profile&rkey=self` 33 32 ).then((res) => res.json()); 34 33 const ref = _.get(profile, "value.avatar.ref.$link"); 35 34 const type = _.get(profile, "value.avatar.mimeType", "").split("/")[1]; ··· 49 48 .limit(1) 50 49 .execute(); 51 50 52 - console.log(u); 51 + const userPayload = { 52 + xata_id: u.id, 53 + did: u.did, 54 + handle: u.handle, 55 + display_name: u.displayName, 56 + avatar: u.avatar, 57 + xata_createdat: u.createdAt.toISOString(), 58 + xata_updatedat: u.updatedAt.toISOString(), 59 + xata_version: profile.user.xataVersion || 1, 60 + }; 61 + 62 + console.log(userPayload); 53 63 54 - ctx.nc.publish( 55 - "rocksky.user", 56 - Buffer.from(JSON.stringify(deepSnakeCaseKeys(u))), 57 - ); 64 + ctx.nc.publish("rocksky.user", Buffer.from(JSON.stringify(userPayload))); 58 65 } 59 66 60 67 console.log("Done");