From b4faa7c4ec7f8557c4b29d4af7db5cdd92a5bb84 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:25:11 +0900 Subject: [PATCH 1/4] chore: Use integrity for Redoc script (#13716) * Use integrity for redoc scripts * official? --- packages/backend/assets/redoc.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/assets/redoc.html b/packages/backend/assets/redoc.html index a9ebf662fc..2557b4532e 100644 --- a/packages/backend/assets/redoc.html +++ b/packages/backend/assets/redoc.html @@ -19,6 +19,6 @@ - + From c687b4eaa558aa3138d81f8fa4d9bbc376d0bd6c Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:28:09 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix(backend):=20nginx=E7=B5=8C=E7=94=B1?= =?UTF-8?q?=E3=81=A7/files/=E3=81=ABRange=E3=83=AA=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=95=E3=82=8C=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E6=AD=A3=E3=81=97=E3=81=8F=E5=BF=9C=E7=AD=94=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#13712)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix files * CHANGELOG --- CHANGELOG.md | 1 + packages/backend/src/server/FileServerService.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a238d99a06..de18aded0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Fix: リプライのみの引用リノートと、CWのみの引用リノートが純粋なリノートとして誤って扱われてしまう問題を修正 - Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606) +- Fix: nginx経由で/files/にRangeリクエストされた場合に正しく応答できないのを修正 ## 2024.3.1 diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index ce7702143e..9db3aa1bfb 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -214,6 +214,8 @@ export class FileServerService { } reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream'); + reply.header('Content-Length', file.file.size); + reply.header('Cache-Control', 'max-age=31536000, immutable'); reply.header('Content-Disposition', contentDisposition( 'inline', @@ -256,6 +258,7 @@ export class FileServerService { return fs.createReadStream(file.path); } else { reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.file.type) ? file.file.type : 'application/octet-stream'); + reply.header('Content-Length', file.file.size); reply.header('Cache-Control', 'max-age=31536000, immutable'); reply.header('Content-Disposition', contentDisposition('inline', file.filename)); @@ -530,9 +533,7 @@ export class FileServerService { if (!file.storedInternal) { if (!(file.isLink && file.uri)) return '204'; const result = await this.downloadAndDetectTypeFromUrl(file.uri); - if (!file.size) { - file.size = (await fs.promises.stat(result.path)).size; - } + file.size = (await fs.promises.stat(result.path)).size; // DB file.sizeは正確とは限らないので return { ...result, url: file.uri, From ca0d148a78bd1277479a38565f08c22cdfb4fcc2 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Mon, 15 Apr 2024 22:11:17 +0900 Subject: [PATCH 3/4] =?UTF-8?q?ci:=20Check=20Misskey=20JS=20autogen?= =?UTF-8?q?=E3=82=92=E6=A7=98=E3=80=85=E6=94=B9=E5=96=84=20(#13718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/check-misskey-js-autogen.yml | 141 +++++++++--------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/.github/workflows/check-misskey-js-autogen.yml b/.github/workflows/check-misskey-js-autogen.yml index 8fad129115..4aa0646b7b 100644 --- a/.github/workflows/check-misskey-js-autogen.yml +++ b/.github/workflows/check-misskey-js-autogen.yml @@ -5,24 +5,23 @@ on: branches: - master - develop + - improve-misskey-js-autogen-check paths: - packages/backend/** jobs: - check-misskey-js-autogen: + # pull_request_target safety: permissions: read-all, and there are no secrets used in this job + generate-misskey-js: runs-on: ubuntu-latest permissions: - pull-requests: write - - env: - api_json_name: "api-head.json" - + contents: read + if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }} steps: - name: checkout uses: actions/checkout@v4.1.1 with: submodules: true - ref: ${{ github.event.pull_request.head.sha }} + ref: refs/pull/${{ github.event.pull_request.number }}/merge - name: setup pnpm uses: pnpm/action-setup@v3 @@ -39,79 +38,81 @@ jobs: - name: install dependencies run: pnpm i --frozen-lockfile - - name: wait get-api-diff - uses: lewagon/wait-on-check-action@v1.3.3 + # generate api.json + - name: Copy Config + run: cp .config/example.yml .config/default.yml + - name: Build + run: pnpm build + - name: Generate API JSON + run: pnpm --filter backend generate-api-json + + # build misskey js + - name: Build misskey-js + run: |- + cp packages/backend/built/api.json packages/misskey-js/generator/api.json + pnpm run --filter misskey-js-type-generator generate + + # packages/misskey-js/generator/built/autogen + - name: Upload Generated + uses: actions/upload-artifact@v4 with: - ref: ${{ github.event.pull_request.head.sha }} - check-regexp: get-from-misskey .+ - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 30 + name: generated-misskey-js + path: packages/misskey-js/generator/built/autogen - - name: Download artifact - uses: actions/github-script@v7.0.1 + # pull_request_target safety: permissions: read-all, and there are no secrets used in this job + get-actual-misskey-js: + runs-on: ubuntu-latest + permissions: + contents: read + if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }} + steps: + - name: checkout + uses: actions/checkout@v4.1.1 with: - script: | - const fs = require('fs'); + submodules: true + ref: refs/pull/${{ github.event.pull_request.number }}/merge - const workflows = await github.rest.actions.listWorkflowRunsForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - head_sha: `${{ github.event.pull_request.head.sha }}` - }).then(x => x.data.workflow_runs); + - name: Upload From Merged + uses: actions/upload-artifact@v4 + with: + name: actual-misskey-js + path: packages/misskey-js/src/autogen - console.log(workflows.map(x => ({name: x.name, title: x.display_title}))); + # pull_request_target safety: nothing is cloned from repository + comment-misskey-js-autogen: + runs-on: ubuntu-latest + needs: [generate-misskey-js, get-actual-misskey-js] + permissions: + pull-requests: write + steps: + - name: download generated-misskey-js + uses: actions/download-artifact@v4 + with: + name: generated-misskey-js + path: misskey-js-generated - const run_id = workflows.find(x => x.name.includes("Get api.json from Misskey")).id; + - name: download actual-misskey-js + uses: actions/download-artifact@v4 + with: + name: actual-misskey-js + path: misskey-js-actual - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: run_id, - }); + - name: check misskey-js changes + id: check-changes + run: | + diff -r -u --label=generated --label=on-tree ./misskey-js-generated ./misskey-js-actual > misskey-js.diff || true - let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name.startsWith("api-artifact-") || artifact.name == "api-artifact" - }); + if [ -s misskey-js.diff ]; then + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "changes=false" >> $GITHUB_OUTPUT + fi - await Promise.all(matchArtifacts.map(async (artifact) => { - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip', - }); - await fs.promises.writeFile(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data)); - })); - - - name: unzip artifacts - run: |- - find . -mindepth 1 -maxdepth 1 -type f -name '*.zip' -exec unzip {} -d . ';' - ls -la - - - name: get head checksum - run: |- - checksum=$(realpath head_checksum) - - cd packages/misskey-js/src - find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum - cd ../../.. - - - name: build autogen - run: |- - checksum=$(realpath ${api_json_name}_checksum) - mv $api_json_name packages/misskey-js/generator/api.json - - cd packages/misskey-js/generator - pnpm run generate - cd built - find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum - cd ../../../.. - - - name: check update for type definitions - run: diff head_checksum ${api_json_name}_checksum + - name: Print full diff + run: cat ./misskey-js.diff - name: send message - if: failure() + if: steps.check-changes.outputs.changes == 'true' uses: thollander/actions-comment-pull-request@v2 with: comment_tag: check-misskey-js-autogen @@ -125,7 +126,7 @@ jobs: ``` - name: send message - if: success() + if: steps.check-changes.outputs.changes == 'false' uses: thollander/actions-comment-pull-request@v2 with: comment_tag: check-misskey-js-autogen From e9e877f64e83bf34f90373a366567b852d3cce18 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 16 Apr 2024 13:37:14 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E3=83=80=E3=82=A4=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E6=8A=95=E7=A8=BF=E3=81=AE=E5=AE=9B=E5=85=88=E3=81=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=20(#1371?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: ダイレクト投稿の宛先が保存されない * fix: 同じユーザーが複数回宛先に追加できる問題 * fix: 関係ないユーザーが宛先に追加される可能性がある --- CHANGELOG.md | 1 + packages/frontend/src/components/MkPostForm.vue | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de18aded0c..4aad65d837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Fix: CWのみの引用リノートが詳細ページで純粋なリノートとして誤って扱われてしまう問題を修正 - Fix: ノート詳細ページにおいてCW付き引用リノートのCWボタンのラベルに「引用」が含まれていない問題を修正 - Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正 +- Fix: ダイレクト投稿の宛先が保存されない問題を修正 ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 014b866fbd..d7efca9de9 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -388,7 +388,7 @@ function addMissingMention() { for (const x of extractMentions(ast)) { if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) { misskeyApi('users/show', { username: x.username, host: x.host }).then(user => { - visibleUsers.value.push(user); + pushVisibleUser(user); }); } } @@ -679,6 +679,7 @@ function saveDraft() { localOnly: localOnly.value, files: files.value, poll: poll.value, + visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(x => x.id) : undefined, }, }; @@ -960,6 +961,15 @@ onMounted(() => { if (draft.data.poll) { poll.value = draft.data.poll; } + if (draft.data.visibleUserIds) { + misskeyApi('users/show', { userIds: draft.data.visibleUserIds }).then(users => { + for (let i = 0; i < users.length; i++) { + if (users[i].id === draft.data.visibleUserIds[i]) { + pushVisibleUser(users[i]); + } + } + }); + } } }