diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 59972bac6..91defb3c4 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -31,7 +31,7 @@ fi cd $CPAD_HOME if [ "$CPAD_INSTALL_ONLYOFFICE" == "yes" ]; then - ./install-onlyoffice.sh --accept-license + ./install-onlyoffice.sh --accept-license --trust-repository fi npm run build diff --git a/install-onlyoffice.sh b/install-onlyoffice.sh index 7be005895..e711837a6 100755 --- a/install-onlyoffice.sh +++ b/install-onlyoffice.sh @@ -69,6 +69,10 @@ parse_arguments() { ACCEPT_LICENSE="1" shift ;; + -t | --trust-repository) + TRUST_REPOSITORY="1" + shift + ;; *) show_help shift @@ -110,17 +114,26 @@ OPTIONS: Accept the license of OnlyOffice and do not ask when running this script. Read and accept this before using this option: https://github.com/ONLYOFFICE/web-apps/blob/master/LICENSE.txt + + -t, --trust-repository + Automatically configure the cloned onlyoffice-builds repository + as a safe.directory. + https://git-scm.com/docs/git-config/#Documentation/git-config.txt-safedirectory + EOF exit 1 } ensure_oo_is_downloaded() { - ensure_command_available git + ensure_command_available git - if ! [ -d "$BUILDS_DIR" ]; then - echo "Downloading OnlyOffice..." - git clone --bare https://github.com/cryptpad/onlyoffice-builds.git "$BUILDS_DIR" - fi + if ! [ -d "$BUILDS_DIR" ]; then + echo "Downloading OnlyOffice..." + git clone --bare https://github.com/cryptpad/onlyoffice-builds.git "$BUILDS_DIR" + fi + if [ ${TRUST_REPOSITORY+x} ] || [ "${PROPS[trust_repository]:-no}" == yes ]; then + git config --global --add safe.directory /cryptpad/onlyoffice-conf/onlyoffice-builds.git + fi } install_version() { diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 4facd8156..12d95112a 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -919,7 +919,10 @@ define([ }; const getMyOOIndex = function() { - return findUserByOOId(myOOId).index; + const user = findUserByOOId(myOOId); + return user + ? user.index + : content.ids.length; // Assign an unused id to read-only users }; var getParticipants = function () { @@ -1478,6 +1481,10 @@ define([ send({ type: "message" }); break; case "saveChanges": + if (readOnly) { + return; + } + // If we have unsaved data before reloading for a checkpoint... if (APP.onStrictSaveChanges) { delete APP.unsavedLocks; diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index 1b3f02231..21bff21ff 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -1055,7 +1055,7 @@ define([ var removeClient = function (ctx, cId) { var idx = ctx.clients.indexOf(cId); - ctx.clients.splice(idx, 1); + if (idx !== -1) { ctx.clients.splice(idx, 1); } Object.keys(ctx.calendars).forEach(function (id) { var cal = ctx.calendars[id];