@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
18 lines • 943 B
JavaScript
;
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"));
const misc_1 = require("@cocalc/util/misc");
async function isCollaborator({ account_id, project_id, }) {
if (!(0, misc_1.is_valid_uuid_string)(account_id) || !(0, misc_1.is_valid_uuid_string)(project_id)) {
throw Error("invalid input");
}
const pool = (0, pool_1.default)("long"); // fine to cache "yes, you're a collab" for a while
const { rows } = await pool.query(`SELECT users#>'{${account_id},group}' AS group FROM projects WHERE project_id=\$1`, [project_id]);
const group = rows[0]?.group;
return group == "owner" || group == "collaborator";
}
exports.default = isCollaborator;
//# sourceMappingURL=is-collaborator.js.map