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

Always set avatar URL and default displayName

Import NotNull from drizzle-orm and remove conditional checks
for profileRecord when setting avatar; set displayName to an empty
string by default.

+13 -9
+13 -9
apps/api/src/xrpc/app/rocksky/actor/getProfile.ts
··· 3 3 import type { OutputSchema } from "@atproto/api/dist/client/types/com/atproto/repo/getRecord"; 4 4 import type { HandlerAuth } from "@atproto/xrpc-server"; 5 5 import type { Context } from "context"; 6 - import { eq } from "drizzle-orm"; 6 + import { eq, NotNull } from "drizzle-orm"; 7 7 import { Effect, pipe } from "effect"; 8 8 import type { Server } from "lexicon"; 9 9 import type { ProfileViewDetailed } from "lexicon/types/app/rocksky/actor/defs"; ··· 302 302 .update(tables.users) 303 303 .set({ 304 304 handle, 305 - avatar: _.get(profile, "profileRecord") 306 - ? `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg` 307 - : null, 308 - displayName: _.get(profile, "profileRecord.value.displayName"), 305 + avatar: `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg`, 306 + displayName: _.get( 307 + profile, 308 + "profileRecord.value.displayName", 309 + "", 310 + ), 309 311 updatedAt: new Date(), 310 312 }) 311 313 .where(eq(tables.users.id, profile.user.id)) ··· 317 319 xata_id: profile.user.id, 318 320 did: profile.user.did, 319 321 handle, 320 - display_name: _.get(profile, "profileRecord.value.displayName"), 321 - avatar: _.get(profile, "profileRecord") 322 - ? `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg` 323 - : undefined, 322 + display_name: _.get( 323 + profile, 324 + "profileRecord.value.displayName", 325 + "", 326 + ), 327 + avatar: `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg`, 324 328 xata_createdat: profile.user.createdAt.toISOString(), 325 329 xata_updatedat: new Date().toISOString(), 326 330 xata_version: (profile.user.xataVersion || 1) + 1,