From 1cd8bfadeddaa409f169f320a04065e4705a1152 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Sep 2021 16:25:30 +0900 Subject: [PATCH 1/7] =?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 2/7] 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", From 608ff73907a142de74aca544fbec823d90ed6dc9 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 5 Sep 2021 23:35:48 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E3=83=AA=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=8B=E3=82=89=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=8C=E9=A3=9B=E3=82=93=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=9F=E3=82=89=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#7768)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Delete Actor * Update src/remote/activitypub/kernel/delete/actor.ts Co-authored-by: syuilo Co-authored-by: syuilo --- src/remote/activitypub/kernel/delete/actor.ts | 26 +++++++++++++++++++ src/remote/activitypub/kernel/delete/index.ts | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/remote/activitypub/kernel/delete/actor.ts diff --git a/src/remote/activitypub/kernel/delete/actor.ts b/src/remote/activitypub/kernel/delete/actor.ts new file mode 100644 index 0000000000..502f8d5ab5 --- /dev/null +++ b/src/remote/activitypub/kernel/delete/actor.ts @@ -0,0 +1,26 @@ +import { apLogger } from '../../logger'; +import { createDeleteAccountJob } from '@/queue'; +import { IRemoteUser } from '@/models/entities/user'; +import { Users } from '@/models/index'; + +const logger = apLogger; + +export async function deleteActor(actor: IRemoteUser, uri: string): Promise { + logger.info(`Deleting the Actor: ${uri}`); + + if (actor.uri !== uri) { + return `skip: delete actor ${actor.uri} !== ${uri}`; + } + + if (actor.isDeleted) { + logger.info(`skip: already deleted`); + } + + const job = await createDeleteAccountJob(actor); + + await Users.update(actor.id, { + isDeleted: true, + }); + + return `ok: queued ${job.name} ${job.id}`; +} diff --git a/src/remote/activitypub/kernel/delete/index.ts b/src/remote/activitypub/kernel/delete/index.ts index 474f3f6d60..86a452de76 100644 --- a/src/remote/activitypub/kernel/delete/index.ts +++ b/src/remote/activitypub/kernel/delete/index.ts @@ -2,6 +2,7 @@ import deleteNote from './note'; import { IRemoteUser } from '@/models/entities/user'; import { IDelete, getApId, isTombstone, IObject, validPost, validActor } from '../../type'; import { toSingle } from '@/prelude/array'; +import { deleteActor } from './actor'; /** * 削除アクティビティを捌きます @@ -41,7 +42,7 @@ export default async (actor: IRemoteUser, activity: IDelete): Promise => if (validPost.includes(formarType)) { return await deleteNote(actor, uri); } else if (validActor.includes(formarType)) { - return `Delete Actor is not implanted`; + return await deleteActor(actor, uri); } else { return `Unknown type ${formarType}`; } From 0281bdd90c021ad882c064977b6673f3b457d204 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Sep 2021 23:36:20 +0900 Subject: [PATCH 4/7] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf00b64e2..ff0a0e6b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ --> +## 12.x.x (unreleased) + +### Improvements +- リモートユーザーのDeleteアクティビティに対応 + +### Bugfixes + ## 12.90.1 (2021/09/05) ### Bugfixes From ba1c57c7bd29232e2054565ee768052149268801 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 6 Sep 2021 01:23:30 +0900 Subject: [PATCH 5/7] =?UTF-8?q?packedNotificationSchema=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/repositories/notification.ts | 34 ++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/models/repositories/notification.ts b/src/models/repositories/notification.ts index 55af96b6d7..4d13940c76 100644 --- a/src/models/repositories/notification.ts +++ b/src/models/repositories/notification.ts @@ -7,6 +7,7 @@ import { Note } from '@/models/entities/note'; import { NoteReaction } from '@/models/entities/note-reaction'; import { User } from '@/models/entities/user'; import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis'; +import { notificationTypes } from '@/types'; export type PackedNotification = SchemaType; @@ -124,20 +125,41 @@ export const packedNotificationSchema = { optional: false as const, nullable: false as const, format: 'date-time', }, + isRead: { + type: 'boolean' as const, + optional: false as const, nullable: false as const, + }, type: { type: 'string' as const, optional: false as const, nullable: false as const, - enum: ['follow', 'followRequestAccepted', 'receiveFollowRequest', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote'], - }, - userId: { - type: 'string' as const, - optional: true as const, nullable: true as const, - format: 'id', + enum: [...notificationTypes], }, user: { type: 'object' as const, ref: 'User', optional: true as const, nullable: true as const, }, + userId: { + type: 'string' as const, + optional: true as const, nullable: true as const, + format: 'id', + }, + note: { + type: 'object' as const, + ref: 'Note', + optional: true as const, nullable: true as const, + }, + reaction: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + body: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, + icon: { + type: 'string' as const, + optional: true as const, nullable: true as const, + }, } }; From 9a089e584e88186ca1fd49db5ca17e23be8be7a8 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 6 Sep 2021 01:23:50 +0900 Subject: [PATCH 6/7] =?UTF-8?q?read:gallery,=20write:gallery,=20read:galle?= =?UTF-8?q?ry-likes,=20write:gallery-likes=E3=81=AB=E7=BF=BB=E8=A8=B3?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 4 ++++ src/misc/api-permissions.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e22f50668f..e5747d5124 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1150,6 +1150,10 @@ _permissions: "write:user-groups": "ユーザーグループを操作する" "read:channels": "チャンネルを見る" "write:channels": "チャンネルを操作する" + "read:gallery": "ギャラリーを見る" + "write:gallery": "ギャラリーを操作する" + "read:gallery-likes": "ギャラリーのいいねを見る" + "write:gallery-likes": "ギャラリーのいいねを操作する" _auth: shareAccess: "「{name}」がアカウントにアクセスすることを許可しますか?" diff --git a/src/misc/api-permissions.ts b/src/misc/api-permissions.ts index eb20c3d289..160cdf9fd6 100644 --- a/src/misc/api-permissions.ts +++ b/src/misc/api-permissions.ts @@ -32,3 +32,4 @@ export const kinds = [ 'read:gallery-likes', 'write:gallery-likes', ]; +// IF YOU ADD KINDS(PERMISSIONS), YOU MUST ADD TRANSLATIONS (under _permissions). From 3bde3e523dedb0b7620cd4ef603f3d50315db7c0 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 6 Sep 2021 01:35:00 +0900 Subject: [PATCH 7/7] fix --- locales/ja-JP.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e5747d5124..b9623ef0d0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1150,10 +1150,10 @@ _permissions: "write:user-groups": "ユーザーグループを操作する" "read:channels": "チャンネルを見る" "write:channels": "チャンネルを操作する" - "read:gallery": "ギャラリーを見る" - "write:gallery": "ギャラリーを操作する" - "read:gallery-likes": "ギャラリーのいいねを見る" - "write:gallery-likes": "ギャラリーのいいねを操作する" + "read:gallery": "ギャラリーを見る" + "write:gallery": "ギャラリーを操作する" + "read:gallery-likes": "ギャラリーのいいねを見る" + "write:gallery-likes": "ギャラリーのいいねを操作する" _auth: shareAccess: "「{name}」がアカウントにアクセスすることを許可しますか?"