Barazo AppView backend barazo.forum
at main 53 lines 1.2 kB view raw
1export interface SourceProfile { 2 did: string 3 handle: string 4 displayName: string | null 5 avatarUrl: string | null 6 bannerUrl: string | null 7 bio: string | null 8} 9 10export interface CommunityOverride { 11 displayName: string | null 12 avatarUrl: string | null 13 bannerUrl: string | null 14 bio: string | null 15} 16 17export interface ResolvedProfile { 18 did: string 19 handle: string 20 displayName: string | null 21 avatarUrl: string | null 22 bannerUrl: string | null 23 bio: string | null 24} 25 26/** 27 * Resolve a user's profile for display in a community context. 28 * Community override fields take precedence; null means "use source." 29 */ 30export function resolveProfile( 31 source: SourceProfile, 32 override: CommunityOverride | null 33): ResolvedProfile { 34 if (!override) { 35 return { 36 did: source.did, 37 handle: source.handle, 38 displayName: source.displayName, 39 avatarUrl: source.avatarUrl, 40 bannerUrl: source.bannerUrl, 41 bio: source.bio, 42 } 43 } 44 45 return { 46 did: source.did, 47 handle: source.handle, 48 displayName: override.displayName ?? source.displayName, 49 avatarUrl: override.avatarUrl ?? source.avatarUrl, 50 bannerUrl: override.bannerUrl ?? source.bannerUrl, 51 bio: override.bio ?? source.bio, 52 } 53}