"use strict";
(() => {
var exports = {};
exports.id = 9398;
exports.ids = [9398];
exports.modules = {

/***/ 439491:
/***/ ((module) => {

module.exports = require("assert");

/***/ }),

/***/ 714300:
/***/ ((module) => {

module.exports = require("buffer");

/***/ }),

/***/ 706113:
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),

/***/ 809523:
/***/ ((module) => {

module.exports = require("dns");

/***/ }),

/***/ 582361:
/***/ ((module) => {

module.exports = require("events");

/***/ }),

/***/ 657147:
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ 113685:
/***/ ((module) => {

module.exports = require("http");

/***/ }),

/***/ 241808:
/***/ ((module) => {

module.exports = require("net");

/***/ }),

/***/ 822037:
/***/ ((module) => {

module.exports = require("os");

/***/ }),

/***/ 371017:
/***/ ((module) => {

module.exports = require("path");

/***/ }),

/***/ 677282:
/***/ ((module) => {

module.exports = require("process");

/***/ }),

/***/ 12781:
/***/ ((module) => {

module.exports = require("stream");

/***/ }),

/***/ 371576:
/***/ ((module) => {

module.exports = require("string_decoder");

/***/ }),

/***/ 924404:
/***/ ((module) => {

module.exports = require("tls");

/***/ }),

/***/ 76224:
/***/ ((module) => {

module.exports = require("tty");

/***/ }),

/***/ 257310:
/***/ ((module) => {

module.exports = require("url");

/***/ }),

/***/ 473837:
/***/ ((module) => {

module.exports = require("util");

/***/ }),

/***/ 852411:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ handle)
/* harmony export */ });
/* harmony import */ var _cocalc_server_public_paths_save__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(549812);
/* harmony import */ var _cocalc_server_public_paths_save__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_cocalc_server_public_paths_save__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lib_account_get_account__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(559459);
/* harmony import */ var lib_api_get_params__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(26438);
/* Request to save a particular public path. */ 


async function handle(req, res) {
    try {
        const account_id = await (0,lib_account_get_account__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(req);
        if (account_id == null) {
            throw Error("must be signed in to save public path (have to be collab on project)");
        }
        const { id  } = (0,lib_api_get_params__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(req);
        if (!id) {
            throw Error("must specify id of public path");
        }
        await _cocalc_server_public_paths_save__WEBPACK_IMPORTED_MODULE_0___default()(id, account_id);
        res.json({});
    } catch (err) {
        res.json({
            error: `${err.message}`
        });
        return;
    }
}


/***/ }),

/***/ 549812:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pool_1 = __importDefault(__webpack_require__(541808));
const is_collaborator_1 = __importDefault(__webpack_require__(126804));
// This sets the last_edited field of the public path to now.  In Kucalc
// that triggers manage-share to copy the files over to the NFS volume
// with the shared files.  In cocalc-docker and dev mode, this doesn't
// trigger anything, since files are served directly from the project, so
// there is no notion of saving them.
//
// TODO: we definitely plan to change cocalc-docker to have
// a separate location for published files, just like kucalc, since then
// you an be sure your files are correct before publishing them, rather than
// having intermediate files available as you go.
//
async function savePublicPath(public_path_id, account_id) {
    const pool = (0, pool_1.default)();
    // figure out project_id and make sure account_id is a collab.
    const { rows } = await pool.query("SELECT project_id FROM public_paths WHERE id=$1", [public_path_id]);
    if (rows.length == 0) {
        throw Error(`no public path with id=${public_path_id}`);
    }
    if (!(await (0, is_collaborator_1.default)({
        account_id,
        project_id: rows[0].project_id,
    }))) {
        throw Error("user must be signed in as collaborator on the project containing the public path");
    }
    // finally, actually update last_edited.
    await pool.query("UPDATE public_paths SET last_edited = NOW() WHERE id=$1", [
        public_path_id,
    ]);
}
exports["default"] = savePublicPath;
//# sourceMappingURL=save.js.map

/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../../webpack-api-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [8180,2921,9557,5245,1808,4006,8312,5710,9459,6394], () => (__webpack_exec__(852411)));
module.exports = __webpack_exports__;

})();