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.

fix: ensure avatar update is skipped based on environment variable

+25 -21
+25 -21
apps/api/src/scripts/avatar.ts
··· 17 17 continue; 18 18 } 19 19 20 - const plc = await fetch(`https://plc.directory/${user.did}`).then((res) => 21 - res.json() 22 - ); 20 + if (!process.env.SKIP_AVATAR_UPDATE) { 21 + const plc = await fetch(`https://plc.directory/${user.did}`).then((res) => 22 + res.json() 23 + ); 23 24 24 - const serviceEndpoint = _.get(plc, "service.0.serviceEndpoint"); 25 - if (!serviceEndpoint) { 26 - console.log(`Service endpoint not found for ${did}`); 27 - continue; 28 - } 25 + const serviceEndpoint = _.get(plc, "service.0.serviceEndpoint"); 26 + if (!serviceEndpoint) { 27 + console.log(`Service endpoint not found for ${did}`); 28 + continue; 29 + } 29 30 30 - const profile = await fetch( 31 - `${serviceEndpoint}/xrpc/com.atproto.repo.getRecord?repo=${user.did}&collection=app.bsky.actor.profile&rkey=self` 32 - ).then((res) => res.json()); 33 - const ref = _.get(profile, "value.avatar.ref.$link"); 34 - const type = _.get(profile, "value.avatar.mimeType", "").split("/")[1]; 35 - await ctx.db 36 - .update(users) 37 - .set({ 38 - displayName: _.get(profile, "value.displayName"), 39 - avatar: `https://cdn.bsky.app/img/avatar/plain/${user.did}/${ref}@${type}`, 40 - }) 41 - .where(eq(users.did, user.did)) 42 - .execute(); 31 + const profile = await fetch( 32 + `${serviceEndpoint}/xrpc/com.atproto.repo.getRecord?repo=${user.did}&collection=app.bsky.actor.profile&rkey=self` 33 + ).then((res) => res.json()); 34 + const ref = _.get(profile, "value.avatar.ref.$link"); 35 + const type = _.get(profile, "value.avatar.mimeType", "").split("/")[1]; 36 + await ctx.db 37 + .update(users) 38 + .set({ 39 + displayName: _.get(profile, "value.displayName"), 40 + avatar: `https://cdn.bsky.app/img/avatar/plain/${user.did}/${ref}@${type}`, 41 + }) 42 + .where(eq(users.did, user.did)) 43 + .execute(); 44 + } else { 45 + console.log(`Skipping avatar update for ${did}`); 46 + } 43 47 44 48 const [u] = await ctx.db 45 49 .select()