diff --git a/.dockerignore b/.dockerignore index e16333fb2..7cef84d94 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/CHANGELOG.md b/CHANGELOG.md index 2454a3b60..2bf00b64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ --> +## 12.90.1 (2021/09/05) + +### Bugfixes +- Dockerfileを修正 +- ノート翻訳時に公開範囲が考慮されていない問題を修正 + ## 12.90.0 (2021/09/04) ### Improvements diff --git a/Dockerfile b/Dockerfile index 8c655c4c4..58e3eda11 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"] + diff --git a/package.json b/package.json index ebb4d9089..90914c76a 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", diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index a8e356abf..9e0f5e55f 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 e4bc6bb06..b56b1debd 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; }