@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
27 lines • 1.04 kB
JavaScript
;
/*
Get the *PUBLIC* profile of a user.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pool_1 = __importDefault(require("@cocalc/database/pool"));
async function getProfile(account_id, noCache = false) {
const pool = (0, pool_1.default)(noCache ? undefined : "long");
// Do not put anything private in this query!!!!
const { rows } = await pool.query("SELECT first_name, last_name, profile, name FROM accounts WHERE account_id=$1", [account_id]);
if (rows.length == 0) {
throw Error(`no account with id ${account_id}`);
}
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,
};
}
exports.default = getProfile;
//# sourceMappingURL=get.js.map