From 65d9c304df06c46ed5e8bfd3d8bc53a84571684c Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Sun, 5 Sep 2021 02:18:12 +0900 Subject: [PATCH 1/3] fix Dockerfile (#7763) * fix Dockerfile * remove unnecessary change * add misskey-assets in .dockerignore --- .dockerignore | 2 +- Dockerfile | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index e16333fb2a..7cef84d940 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ .autogen -.git .github .travis .vscode @@ -12,3 +11,4 @@ elasticsearch/ node_modules/ redis/ files/ +misskey-assets/ diff --git a/Dockerfile b/Dockerfile index 8c655c4c4f..58e3eda119 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,27 +4,17 @@ ENV NODE_ENV=production WORKDIR /misskey +ENV BUILD_DEPS autoconf automake file g++ gcc libc-dev libtool make nasm pkgconfig python3 zlib-dev git + FROM base AS builder -RUN apk add --no-cache \ - autoconf \ - automake \ - file \ - g++ \ - gcc \ - libc-dev \ - libtool \ - make \ - nasm \ - pkgconfig \ - python3 \ - zlib-dev - -RUN git submodule update --init -COPY package.json yarn.lock .yarnrc ./ -RUN yarn install COPY . ./ -RUN yarn build + +RUN apk add --no-cache $BUILD_DEPS && \ + git submodule update --init && \ + yarn install && \ + yarn build && \ + rm -rf .git FROM base AS runner @@ -39,3 +29,4 @@ COPY --from=builder /misskey/built ./built COPY . ./ CMD ["npm", "run", "migrateandstart"] + From 1cd8bfadeddaa409f169f320a04065e4705a1152 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Sep 2021 16:25:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix(server):=20=E3=83=8E=E3=83=BC=E3=83=88?= =?UTF-8?q?=E7=BF=BB=E8=A8=B3=E6=99=82=E3=81=AB=E5=85=AC=E9=96=8B=E7=AF=84?= =?UTF-8?q?=E5=9B=B2=E3=81=8C=E8=80=83=E6=85=AE=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++ src/models/repositories/note.ts | 50 +++++++++++++++++++++ src/server/api/endpoints/notes/translate.ts | 5 +++ 3 files changed, 61 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2454a3b609..c14fb48177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ --> +## 12.x.x (unreleased) + +### Bugfixes +- Dockerfileを修正 +- ノート翻訳時に公開範囲が考慮されていない問題を修正 + ## 12.90.0 (2021/09/04) ### Improvements diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index a8e356abf2..9e0f5e55f0 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -18,7 +18,57 @@ export class NoteRepository extends Repository { return x.trim().length <= 100; } + public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise { + // visibility が specified かつ自分が指定されていなかったら非表示 + if (note.visibility === 'specified') { + if (meId == null) { + return false; + } else if (meId === note.userId) { + return true; + } else { + // 指定されているかどうか + const specified = note.visibleUserIds.some((id: any) => meId === id); + + if (specified) { + return true; + } else { + return false; + } + } + } + + // visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示 + if (note.visibility === 'followers') { + if (meId == null) { + return false; + } else if (meId === note.userId) { + return true; + } else if (note.reply && (meId === note.reply.userId)) { + // 自分の投稿に対するリプライ + return true; + } else if (note.mentions && note.mentions.some(id => meId === id)) { + // 自分へのメンション + return true; + } else { + // フォロワーかどうか + const following = await Followings.findOne({ + followeeId: note.userId, + followerId: meId + }); + + if (following == null) { + return false; + } else { + return true; + } + } + } + + return true; + } + private async hideNote(packedNote: PackedNote, meId: User['id'] | null) { + // TODO: isVisibleForMe を使うようにしても良さそう(型違うけど) let hide = false; // visibility が specified かつ自分が指定されていなかったら非表示 diff --git a/src/server/api/endpoints/notes/translate.ts b/src/server/api/endpoints/notes/translate.ts index e4bc6bb060..b56b1debdd 100644 --- a/src/server/api/endpoints/notes/translate.ts +++ b/src/server/api/endpoints/notes/translate.ts @@ -8,6 +8,7 @@ import config from '@/config/index'; import { getAgentByUrl } from '@/misc/fetch'; import { URLSearchParams } from 'url'; import { fetchMeta } from '@/misc/fetch-meta'; +import { Notes } from '@/models'; export const meta = { tags: ['notes'], @@ -43,6 +44,10 @@ export default define(meta, async (ps, user) => { throw e; }); + if (!(await Notes.isVisibleForMe(note, user ? user.id : null))) { + return 204; // TODO: 良い感じのエラー返す + } + if (note.text == null) { return 204; } From cc756209764bef11709c71352b1402514174162a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Sep 2021 16:26:24 +0900 Subject: [PATCH 3/3] 12.90.1 --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c14fb48177..2bf00b64e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ --> -## 12.x.x (unreleased) +## 12.90.1 (2021/09/05) ### Bugfixes - Dockerfileを修正 diff --git a/package.json b/package.json index ebb4d90897..90914c76a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "12.90.0", + "version": "12.90.1", "codename": "indigo", "repository": { "type": "git",