@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
22 lines • 1.07 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.associatedLicense = void 0;
const pool_1 = __importDefault(require("@cocalc/database/pool"));
// Return the id of a site license if it should be applied to projects that use
// the given shared document. Otherwise, return null;
async function associatedLicense(public_path_id) {
const pool = (0, pool_1.default)("short");
const { rows } = await pool.query("SELECT site_license_id, disabled, unlisted FROM public_paths WHERE id=$1", [public_path_id]);
const { disabled, unlisted, site_license_id } = rows[0] ?? {};
if (site_license_id && !disabled && unlisted) {
// These are the only conditions under which we would apply a license.
// Apply site_license_id to project_id.
return site_license_id;
}
return null;
}
exports.associatedLicense = associatedLicense;
//# sourceMappingURL=public-path.js.map