From 360b59a458e2eed4f7fcd72d68c3e956ffa88294 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 4 Mar 2026 09:59:00 +0100 Subject: [PATCH] fix(docmost): register NoopAuditService globally when EE submodule is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docmost v0.70.0 added audit logging (enterprise feature). The EE code lives in a private git submodule (apps/server/src/ee) which is NOT included in GitHub tarballs used by fetch_and_deploy_gh_release. Without the submodule, AUDIT_SERVICE (Symbol) is provided by CoreModule via NoopAuditService but only exported – child modules like UserModule cannot resolve it because NestJS DI is scope-based. The EE module would normally register the real service as @Global(), making it available everywhere. Fix: when the EE submodule is absent, patch CoreModule to be @Global() before building, so NoopAuditService is available to all modules. Closes #12548 --- ct/docmost.sh | 11 +++++++++++ install/docmost-install.sh | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/ct/docmost.sh b/ct/docmost.sh index 407e15fd0..15d09cceb 100644 --- a/ct/docmost.sh +++ b/ct/docmost.sh @@ -48,6 +48,17 @@ function update_script() { cd /opt/docmost mv /opt/.env /opt/docmost/.env mv /opt/data /opt/docmost/data + + # Fix: Docmost EE (audit logs etc.) lives in a git submodule that is NOT + # included in GitHub tarballs. The community NoopAuditService exists but + # is only exported by CoreModule – child modules such as UserModule cannot + # resolve it. Making CoreModule @Global() exposes the token app-wide. + if [[ ! -f /opt/docmost/apps/server/src/ee/ee.module.ts ]] \ + && ! grep -q '@Global()' /opt/docmost/apps/server/src/core/core.module.ts 2>/dev/null; then + sed -i '/^ Module,$/a\ Global,' /opt/docmost/apps/server/src/core/core.module.ts + sed -i '/^@Module({$/i @Global()' /opt/docmost/apps/server/src/core/core.module.ts + fi + $STD pnpm install --force $STD pnpm build msg_ok "Updated ${APP}" diff --git a/install/docmost-install.sh b/install/docmost-install.sh index 2d1d643f2..2c1d92522 100644 --- a/install/docmost-install.sh +++ b/install/docmost-install.sh @@ -26,6 +26,17 @@ fetch_and_deploy_gh_release "docmost" "docmost/docmost" "tarball" msg_info "Configuring Docmost (Patience)" cd /opt/docmost + +# Fix: Docmost EE (audit logs etc.) lives in a git submodule that is NOT +# included in GitHub tarballs. The community NoopAuditService exists but +# is only exported by CoreModule – child modules such as UserModule cannot +# resolve it. Making CoreModule @Global() exposes the token app-wide. +if [[ ! -f /opt/docmost/apps/server/src/ee/ee.module.ts ]] \ + && ! grep -q '@Global()' /opt/docmost/apps/server/src/core/core.module.ts 2>/dev/null; then + sed -i '/^ Module,$/a\ Global,' /opt/docmost/apps/server/src/core/core.module.ts + sed -i '/^@Module({$/i @Global()' /opt/docmost/apps/server/src/core/core.module.ts +fi + mv .env.example .env mkdir data sed -i -e "s|APP_SECRET=.*|APP_SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)|" \