22 lines
556 B
JavaScript
22 lines
556 B
JavaScript
export function curateUser(user, assets = {}) {
|
|
if (!user) {
|
|
return null;
|
|
}
|
|
|
|
const curatedStashes = assets.stashes?.filter(Boolean).map((stash) => curateStash(stash)) || [];
|
|
|
|
const curatedUser = {
|
|
id: user.id,
|
|
username: user.username,
|
|
email: user.email,
|
|
emailVerified: user.email_verified,
|
|
identityVerified: user.identity_verified,
|
|
avatar: `/media/avatars/${user.id}_${user.username}.png`,
|
|
createdAt: user.created_at,
|
|
stashes: curatedStashes,
|
|
primaryStash: curatedStashes.find((stash) => stash.primary),
|
|
};
|
|
|
|
return curatedUser;
|
|
}
|