import getPool from "@cocalc/database/pool" ; import { Profile } from "./types" ; export default async function getPrivateProfile ( account_id , noCache = false ) { const pool = getPool ( noCache ? undefined : "medium" ) ; const { rows } = await pool . query ( "SELECT first_name, last_name, profile, name, groups, email_address, passports FROM accounts WHERE account_id=$1" , [ account_id ] ) ; if ( rows . length == 0 ) { throw Error ( `no account with id ${ account_id }` ) ; } const is_admin = ! ! rows [ 0 ] . groups ?. includes ( "admin" ) ; const is_anonymous = ! rows [ 0 ] . email_address && ! rows [ 0 ] . passports ; return { account_id , first_name : rows [ 0 ] . first_name ?? "Anonymous" , last_name : rows [ 0 ] . last_name ?? "User" , image : rows [ 0 ] . profile ?. image , color : rows [ 0 ] . profile ?. color , name : rows [ 0 ] . name , is_admin , is_anonymous , } ; }