"use strict";
/*
Get the *public* profile for an account.

This is public information if user the user knows
the account_id.  It is the color, the name, and
the image.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const get_1 = __importDefault(require("@cocalc/server/accounts/profile/get"));
const private_1 = __importDefault(require("@cocalc/server/accounts/profile/private"));
const get_account_1 = __importDefault(require("lib/account/get-account"));
const get_params_1 = __importDefault(require("lib/api/get-params"));
async function handle(req, res) {
    const { account_id, noCache } = (0, get_params_1.default)(req);
    try {
        if (account_id == null) {
            res.json({ profile: await getPrivate(req, noCache) });
        }
        else {
            res.json({ profile: await (0, get_1.default)(account_id, noCache) });
        }
    }
    catch (err) {
        res.json({ error: err.message });
    }
}
exports.default = handle;
async function getPrivate(req, noCache) {
    const account_id = await (0, get_account_1.default)(req, noCache);
    if (account_id == null) {
        return {};
    }
    return await (0, private_1.default)(account_id, noCache);
}
//# sourceMappingURL=profile.js.map