diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 8b53ad0..250a732 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -56,7 +56,7 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'ci:deployable') runs-on: ubuntu-latest - environment: ${{ needs.namer.outputs.branch == 'staging' && github.actor == github.triggering_actor && 'staging' || 'manual-staging' }} + environment: manual-staging env: pull_image: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_USERNAME }}:${{ needs.namer.outputs.tag }} diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 3c755cb..f705421 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -7,7 +7,7 @@ on: jobs: prepare: - if: github.triggering_actor == 'niqzart' + if: github.triggering_actor == 'niqzart' || github.triggering_actor == 'unknownproperty' uses: ./.github/workflows/common-work.yml with: tag: hocus-main @@ -15,7 +15,7 @@ jobs: secrets: inherit deploy_production: - if: github.triggering_actor == 'niqzart' + if: github.triggering_actor == 'niqzart' || github.triggering_actor == 'unknownproperty' needs: prepare runs-on: ubuntu-latest environment: production diff --git a/src/common/fetcher.ts b/src/common/fetcher.ts index 8230dac..42cf0a7 100644 --- a/src/common/fetcher.ts +++ b/src/common/fetcher.ts @@ -1,8 +1,8 @@ import { logServerError } from "./errors" -const back2BaseUrl = process.env.BACK_2_BASE_URL || "http://localhost:5000" +const back2BaseUrl = process.env.BACK_2__BASE_URL || "http://localhost:5000" const back2BasePath = "/internal/storage-service/v2" -const back2ApiKey = process.env.BACK_2_API_KEY || "local" +const back2ApiKey = process.env.BACK_2__API_KEY || "local" export async function fetchStorage(path: string, init?: RequestInit): Promise { try { diff --git a/src/hooks/download.ts b/src/hooks/download.ts index fcdb538..3232909 100644 --- a/src/hooks/download.ts +++ b/src/hooks/download.ts @@ -1,6 +1,6 @@ import { fetchPayload } from "@hocuspocus/server" -import { HocusPocusError, logServerError } from "../common/errors" +import { HocusPocusError } from "../common/errors" import { fetchStorageSafely } from "../common/fetcher" export async function downloadYDocContent({ documentName }: fetchPayload): Promise { @@ -11,24 +11,11 @@ export async function downloadYDocContent({ documentName }: fetchPayload): Promi throw new HocusPocusError() } - if (response.headers.get("content-length") === "0") { + const arrayBuffer = await response.arrayBuffer() + + if (!arrayBuffer || arrayBuffer.byteLength === 0) { return null } - const responseBody = response.body - if (!responseBody) { - logServerError("Download: body is not present") - throw new HocusPocusError() - } - const data = await response.body.getReader().read() - if (!data) { - logServerError("Download: body read failed") - throw new HocusPocusError() - } - const result = data.value - if (!result) { - logServerError("Download: body value is empty") - throw new HocusPocusError() - } - return result + return new Uint8Array(arrayBuffer) } diff --git a/src/index.ts b/src/index.ts index ed6a187..c7b1336 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,11 @@ const server = Server.configure({ quiet: true, onAuthenticate: verifyYDocAccess, extensions: [ - new Logger(), + new Logger( + { + onChange: process.env.ENABLE_CHANGE_LOGS === "true", + } + ), new Database({ fetch: downloadYDocContent, store: storeYDocContent,