UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

27 lines 1.19 kB
"use strict"; // If no such account or no name set, returns "Unknown User". // Answers are cached for a while. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNameByEmail = void 0; const pool_1 = __importDefault(require("@cocalc/database/pool")); async function getName(account_id) { const pool = (0, pool_1.default)("long"); const { rows } = await pool.query("SELECT first_name, last_name FROM accounts WHERE account_id=$1", [account_id]); return rowsToName(rows); } exports.default = getName; async function getNameByEmail(email_address) { const pool = (0, pool_1.default)("long"); const { rows } = await pool.query("SELECT first_name, last_name FROM accounts WHERE email_address=$1", [email_address]); return rowsToName(rows); } exports.getNameByEmail = getNameByEmail; function rowsToName(rows) { if (rows.length == 0 || (!rows[0].first_name && !rows[0].last_name)) return; return [rows[0].first_name ?? "", rows[0].last_name ?? ""].join(" "); } //# sourceMappingURL=get-name.js.map