diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4453b84de9..377174eb4a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,18 +1,25 @@
## 2024.8.0
### General
-- Fix: リモートユーザのフォロー・フォロワーの一覧が非公開設定の場合も表示できてしまう問題を修正
- Enhance: モデレーターはすべてのユーザーのフォロー・フォロワーの一覧を見られるように
- Feat: 編集された投稿の受信と投稿の編集ができるように
+- Enhance: アカウントの削除のモデレーションログを残すように
+- Enhance: 不適切なページ、ギャラリー、Playを管理者権限で削除できるように
+- Fix: リモートユーザのフォロー・フォロワーの一覧が非公開設定の場合も表示できてしまう問題を修正
### Client
- Enhance: 「自分のPlay」ページにおいてPlayが非公開かどうかが一目でわかるように
+- Enhance: 不適切なページ、ギャラリー、Playを通報できるように
- Fix: Play編集時に公開範囲が「パブリック」にリセットされる問題を修正
- Fix: ページ遷移に失敗することがある問題を修正
- Fix: iOSでユーザー名などがリンクとして誤検知される現象を抑制
- Fix: mCaptchaを使用していてもbotプロテクションに関する警告が消えないのを修正
+- Fix: ユーザーのモデレーションページにおいてユーザー名にドットが入っているとシステムアカウントとして表示されてしまう問題を修正
+- Fix: 特定の条件下でノートの削除ボタンが出ないのを修正
### Server
+- Enhance: 照会時にURLがhtmlかつheadタグ内に`rel="alternate"`, `type="application/activity+json"`の`link`タグがある場合に追ってリンク先を照会できるように
+- Enhance: 凍結されたアカウントのフォローリクエストを表示しないように
- Fix: WSの`readAllNotifications` メッセージが `body` を持たない場合に動作しない問題 #14374
- 通知ページや通知カラム(デッキ)を開いている状態において、新たに発生した通知が既読されない問題が修正されます。
- これにより、プッシュ通知が有効な同条件下の環境において、プッシュ通知が常に発生してしまう問題も修正されます。
@@ -23,6 +30,10 @@
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/679)
- Fix: ActivityPubのエンティティタイプ判定で不明なタイプを受け取った場合でも処理を継続するように
- キュー処理のつまりが改善される可能性があります
+- Fix: リバーシの対局設定の変更が反映されないのを修正
+- Fix: 無制限にストリーミングのチャンネルに接続できる問題を修正
+- Fix: ベースロールのポリシーを変更した際にモデログに記録されないのを修正
+ (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/700)
## 2024.7.0
diff --git a/locales/en-US.yml b/locales/en-US.yml
index fe2bb08074..a02d7fa804 100644
--- a/locales/en-US.yml
+++ b/locales/en-US.yml
@@ -182,7 +182,7 @@ addAccount: "Add account"
reloadAccountsList: "Reload account list"
loginFailed: "Failed to sign in"
showOnRemote: "View on remote instance"
-continueOnRemote: "リモートで続行"
+continueOnRemote: "Continue on a remote server"
chooseServerOnMisskeyHub: "Choose a server from the Misskey Hub"
specifyServerHost: "Specify a server host directly"
inputHostName: "Enter the domain"
@@ -487,7 +487,7 @@ noMessagesYet: "No messages yet"
newMessageExists: "There are new messages"
onlyOneFileCanBeAttached: "You can only attach one file to a message"
signinRequired: "Please register or sign in before continuing"
-signinOrContinueOnRemote: "To continue, you need to move your server or sign up / log in to this server."
+signinOrContinueOnRemote: "To continue, you need to move your server or sign up / log in to this server."
invitations: "Invites"
invitationCode: "Invitation code"
checking: "Checking..."
@@ -2499,6 +2499,7 @@ _moderationLogTypes:
createAbuseReportNotificationRecipient: "Create a recipient for abuse reports"
updateAbuseReportNotificationRecipient: "Update recipients for abuse reports"
deleteAbuseReportNotificationRecipient: "Delete a recipient for abuse reports"
+ deleteFlash: "Delete Play"
_fileViewer:
title: "File details"
type: "File type"
diff --git a/locales/es-ES.yml b/locales/es-ES.yml
index ef066a37ed..2621965d1b 100644
--- a/locales/es-ES.yml
+++ b/locales/es-ES.yml
@@ -60,6 +60,7 @@ copyFileId: "Copiar ID del archivo"
copyFolderId: "Copiar ID de carpeta"
copyProfileUrl: "Copiar la URL del perfil"
searchUser: "Buscar un usuario"
+searchThisUsersNotes: ""
reply: "Responder"
loadMore: "Ver más"
showMore: "Ver más"
diff --git a/locales/index.d.ts b/locales/index.d.ts
index ecf2105ceb..5ac7b19292 100644
--- a/locales/index.d.ts
+++ b/locales/index.d.ts
@@ -2833,7 +2833,7 @@ export interface Locale extends ILocale {
*/
"reportAbuseOf": ParameterizedString<"name">;
/**
- * 通報理由の詳細を記入してください。対象のノートがある場合はそのURLも記入してください。
+ * 通報理由の詳細を記入してください。対象のノートやページなどがある場合はそのURLも記入してください。
*/
"fillAbuseReportDescription": string;
/**
@@ -8989,6 +8989,10 @@ export interface Locale extends ILocale {
* ブロックを追加
*/
"chooseBlock": string;
+ /**
+ * セクションタイトルを入力
+ */
+ "enterSectionTitle": string;
/**
* 種類を選択
*/
@@ -9683,6 +9687,22 @@ export interface Locale extends ILocale {
* 通報の通知先を削除
*/
"deleteAbuseReportNotificationRecipient": string;
+ /**
+ * アカウントを削除
+ */
+ "deleteAccount": string;
+ /**
+ * ページを削除
+ */
+ "deletePage": string;
+ /**
+ * Playを削除
+ */
+ "deleteFlash": string;
+ /**
+ * ギャラリーの投稿を削除
+ */
+ "deleteGalleryPost": string;
};
"_fileViewer": {
/**
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 4860d2c3ac..0d2362d654 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -704,7 +704,7 @@ abuseReports: "通報"
reportAbuse: "通報"
reportAbuseRenote: "リノートを通報"
reportAbuseOf: "{name}を通報する"
-fillAbuseReportDescription: "通報理由の詳細を記入してください。対象のノートがある場合はそのURLも記入してください。"
+fillAbuseReportDescription: "通報理由の詳細を記入してください。対象のノートやページなどがある場合はそのURLも記入してください。"
abuseReported: "内容が送信されました。ご報告ありがとうございました。"
reporter: "通報者"
reporteeOrigin: "通報先"
@@ -2372,6 +2372,7 @@ _pages:
eyeCatchingImageSet: "アイキャッチ画像を設定"
eyeCatchingImageRemove: "アイキャッチ画像を削除"
chooseBlock: "ブロックを追加"
+ enterSectionTitle: "セクションタイトルを入力"
selectType: "種類を選択"
contentBlocks: "コンテンツ"
inputBlocks: "入力"
@@ -2568,6 +2569,10 @@ _moderationLogTypes:
createAbuseReportNotificationRecipient: "通報の通知先を作成"
updateAbuseReportNotificationRecipient: "通報の通知先を更新"
deleteAbuseReportNotificationRecipient: "通報の通知先を削除"
+ deleteAccount: "アカウントを削除"
+ deletePage: "ページを削除"
+ deleteFlash: "Playを削除"
+ deleteGalleryPost: "ギャラリーの投稿を削除"
_fileViewer:
title: "ファイルの詳細"
diff --git a/locales/pt-PT.yml b/locales/pt-PT.yml
index d4c07a28c5..87f934201c 100644
--- a/locales/pt-PT.yml
+++ b/locales/pt-PT.yml
@@ -1675,7 +1675,7 @@ _role:
descriptionOfPermission: "Moderador permite que você execute operações básicas relacionadas à moderação.\nAdministradores podem alterar todas as configurações do servidor."
assignTarget: "Atribuir"
descriptionOfAssignTarget: "Manual para gerenciar manualmente quem está incluído neste cargo.\nCondicional define uma condição e os usuários que corresponderem a ela serão incluídos automaticamente."
- manual: "Documentação"
+ manual: "Manual"
manualRoles: "Cargos manuais"
conditional: "Condicional"
conditionalRoles: "Cargos condicionais"
diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml
index 7b68a5cfdb..f55d65e343 100644
--- a/locales/zh-CN.yml
+++ b/locales/zh-CN.yml
@@ -2499,6 +2499,8 @@ _moderationLogTypes:
createAbuseReportNotificationRecipient: "新建了举报通知"
updateAbuseReportNotificationRecipient: "更新了举报通知"
deleteAbuseReportNotificationRecipient: "删除了举报通知"
+ deletePage: "删除了页面"
+ deleteFlash: "删除了 Play"
_fileViewer:
title: "文件信息"
type: "文件类型"
diff --git a/package.json b/package.json
index 1b8b1cc33e..254c2bee87 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "misskey",
- "version": "2024.8.0-alpha.0",
+ "version": "2024.8.0-rc.3",
"codename": "nasubi",
"repository": {
"type": "git",
@@ -61,7 +61,7 @@
"glob": "11.0.0"
},
"devDependencies": {
- "@misskey-dev/eslint-plugin": "2.0.2",
+ "@misskey-dev/eslint-plugin": "2.0.3",
"@types/node": "20.14.12",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
diff --git a/packages/backend/src/core/DeleteAccountService.ts b/packages/backend/src/core/DeleteAccountService.ts
index 79b614edba..7f1b8f3efb 100644
--- a/packages/backend/src/core/DeleteAccountService.ts
+++ b/packages/backend/src/core/DeleteAccountService.ts
@@ -4,12 +4,15 @@
*/
import { Inject, Injectable } from '@nestjs/common';
-import type { UsersRepository } from '@/models/_.js';
+import { Not, IsNull } from 'typeorm';
+import type { FollowingsRepository, MiUser, UsersRepository } from '@/models/_.js';
import { QueueService } from '@/core/QueueService.js';
-import { UserSuspendService } from '@/core/UserSuspendService.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
+import { UserEntityService } from '@/core/entities/UserEntityService.js';
+import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
@Injectable()
export class DeleteAccountService {
@@ -17,9 +20,14 @@ export class DeleteAccountService {
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
- private userSuspendService: UserSuspendService,
+ @Inject(DI.followingsRepository)
+ private followingsRepository: FollowingsRepository,
+
+ private userEntityService: UserEntityService,
+ private apRendererService: ApRendererService,
private queueService: QueueService,
private globalEventService: GlobalEventService,
+ private moderationLogService: ModerationLogService,
) {
}
@@ -27,16 +35,52 @@ export class DeleteAccountService {
public async deleteAccount(user: {
id: string;
host: string | null;
- }): Promise {
+ }, moderator?: MiUser): Promise {
const _user = await this.usersRepository.findOneByOrFail({ id: user.id });
if (_user.isRoot) throw new Error('cannot delete a root account');
- // 物理削除する前にDelete activityを送信する
- await this.userSuspendService.doPostSuspend(user).catch(e => {});
+ if (moderator != null) {
+ this.moderationLogService.log(moderator, 'deleteAccount', {
+ userId: user.id,
+ userUsername: _user.username,
+ userHost: user.host,
+ });
+ }
- this.queueService.createDeleteAccountJob(user, {
- soft: false,
- });
+ // 物理削除する前にDelete activityを送信する
+ if (this.userEntityService.isLocalUser(user)) {
+ // 知り得る全SharedInboxにDelete配信
+ const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user));
+
+ const queue: string[] = [];
+
+ const followings = await this.followingsRepository.find({
+ where: [
+ { followerSharedInbox: Not(IsNull()) },
+ { followeeSharedInbox: Not(IsNull()) },
+ ],
+ select: ['followerSharedInbox', 'followeeSharedInbox'],
+ });
+
+ const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);
+
+ for (const inbox of inboxes) {
+ if (inbox != null && !queue.includes(inbox)) queue.push(inbox);
+ }
+
+ for (const inbox of queue) {
+ this.queueService.deliver(user, content, inbox, true);
+ }
+
+ this.queueService.createDeleteAccountJob(user, {
+ soft: false,
+ });
+ } else {
+ // リモートユーザーの削除は、完全にDBから物理削除してしまうと再度連合してきてアカウントが復活する可能性があるため、soft指定する
+ this.queueService.createDeleteAccountJob(user, {
+ soft: true,
+ });
+ }
await this.usersRepository.update(user.id, {
isDeleted: true,
diff --git a/packages/backend/src/core/ReversiService.ts b/packages/backend/src/core/ReversiService.ts
index 7f939b99c7..51dca3da59 100644
--- a/packages/backend/src/core/ReversiService.ts
+++ b/packages/backend/src/core/ReversiService.ts
@@ -6,6 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import * as Redis from 'ioredis';
import { ModuleRef } from '@nestjs/core';
+import { reversiUpdateKeys } from 'misskey-js';
import * as Reversi from 'misskey-reversi';
import { IsNull, LessThan, MoreThan } from 'typeorm';
import type {
@@ -399,7 +400,33 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
}
@bindThis
- public async updateSettings(gameId: MiReversiGame['id'], user: MiUser, key: string, value: any) {
+ public isValidReversiUpdateKey(key: unknown): key is typeof reversiUpdateKeys[number] {
+ if (typeof key !== 'string') return false;
+ return (reversiUpdateKeys as string[]).includes(key);
+ }
+
+ @bindThis
+ public isValidReversiUpdateValue(key: K, value: unknown): value is MiReversiGame[K] {
+ switch (key) {
+ case 'map':
+ return Array.isArray(value) && value.every(row => typeof row === 'string');
+ case 'bw':
+ return typeof value === 'string' && ['random', '1', '2'].includes(value);
+ case 'isLlotheo':
+ return typeof value === 'boolean';
+ case 'canPutEverywhere':
+ return typeof value === 'boolean';
+ case 'loopedBoard':
+ return typeof value === 'boolean';
+ case 'timeLimitForEachTurn':
+ return typeof value === 'number' && value >= 0;
+ default:
+ return false;
+ }
+ }
+
+ @bindThis
+ public async updateSettings(gameId: MiReversiGame['id'], user: MiUser, key: K, value: MiReversiGame[K]) {
const game = await this.get(gameId);
if (game == null) throw new Error('game not found');
if (game.isStarted) return;
@@ -407,10 +434,6 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
if ((game.user1Id === user.id) && game.user1Ready) return;
if ((game.user2Id === user.id) && game.user2Ready) return;
- if (!['map', 'bw', 'isLlotheo', 'canPutEverywhere', 'loopedBoard', 'timeLimitForEachTurn'].includes(key)) return;
-
- // TODO: より厳格なバリデーション
-
const updatedGame = {
...game,
[key]: value,
diff --git a/packages/backend/src/core/UserSuspendService.ts b/packages/backend/src/core/UserSuspendService.ts
index d594a223f4..7920e58e36 100644
--- a/packages/backend/src/core/UserSuspendService.ts
+++ b/packages/backend/src/core/UserSuspendService.ts
@@ -5,7 +5,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { Not, IsNull } from 'typeorm';
-import type { FollowingsRepository } from '@/models/_.js';
+import type { FollowingsRepository, FollowRequestsRepository, UsersRepository } from '@/models/_.js';
import type { MiUser } from '@/models/User.js';
import { QueueService } from '@/core/QueueService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
@@ -13,24 +13,75 @@ import { DI } from '@/di-symbols.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
+import { RelationshipJobData } from '@/queue/types.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
@Injectable()
export class UserSuspendService {
constructor(
+ @Inject(DI.usersRepository)
+ private usersRepository: UsersRepository,
+
@Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository,
+ @Inject(DI.followRequestsRepository)
+ private followRequestsRepository: FollowRequestsRepository,
+
private userEntityService: UserEntityService,
private queueService: QueueService,
private globalEventService: GlobalEventService,
private apRendererService: ApRendererService,
+ private moderationLogService: ModerationLogService,
) {
}
@bindThis
- public async doPostSuspend(user: { id: MiUser['id']; host: MiUser['host'] }): Promise {
+ public async suspend(user: MiUser, moderator: MiUser): Promise {
+ await this.usersRepository.update(user.id, {
+ isSuspended: true,
+ });
+
+ this.moderationLogService.log(moderator, 'suspend', {
+ userId: user.id,
+ userUsername: user.username,
+ userHost: user.host,
+ });
+
+ (async () => {
+ await this.postSuspend(user).catch(e => {});
+ await this.unFollowAll(user).catch(e => {});
+ })();
+ }
+
+ @bindThis
+ public async unsuspend(user: MiUser, moderator: MiUser): Promise {
+ await this.usersRepository.update(user.id, {
+ isSuspended: false,
+ });
+
+ this.moderationLogService.log(moderator, 'unsuspend', {
+ userId: user.id,
+ userUsername: user.username,
+ userHost: user.host,
+ });
+
+ (async () => {
+ await this.postUnsuspend(user).catch(e => {});
+ })();
+ }
+
+ @bindThis
+ private async postSuspend(user: { id: MiUser['id']; host: MiUser['host'] }): Promise {
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: true });
+ this.followRequestsRepository.delete({
+ followeeId: user.id,
+ });
+ this.followRequestsRepository.delete({
+ followerId: user.id,
+ });
+
if (this.userEntityService.isLocalUser(user)) {
// 知り得る全SharedInboxにDelete配信
const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user));
@@ -58,7 +109,7 @@ export class UserSuspendService {
}
@bindThis
- public async doPostUnsuspend(user: MiUser): Promise {
+ private async postUnsuspend(user: MiUser): Promise {
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: false });
if (this.userEntityService.isLocalUser(user)) {
@@ -86,4 +137,26 @@ export class UserSuspendService {
}
}
}
+
+ @bindThis
+ private async unFollowAll(follower: MiUser) {
+ const followings = await this.followingsRepository.find({
+ where: {
+ followerId: follower.id,
+ followeeId: Not(IsNull()),
+ },
+ });
+
+ const jobs: RelationshipJobData[] = [];
+ for (const following of followings) {
+ if (following.followeeId && following.followerId) {
+ jobs.push({
+ from: { id: following.followerId },
+ to: { id: following.followeeId },
+ silent: true,
+ });
+ }
+ }
+ this.queueService.createUnfollowJob(jobs);
+ }
}
diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts
index 93ac8ce9a7..7cf8359212 100644
--- a/packages/backend/src/core/activitypub/ApRequestService.ts
+++ b/packages/backend/src/core/activitypub/ApRequestService.ts
@@ -6,6 +6,7 @@
import * as crypto from 'node:crypto';
import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common';
+import { Window } from 'happy-dom';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import type { MiUser } from '@/models/User.js';
@@ -180,7 +181,8 @@ export class ApRequestService {
* @param url URL to fetch
*/
@bindThis
- public async signedGet(url: string, user: { id: MiUser['id'] }): Promise {
+ public async signedGet(url: string, user: { id: MiUser['id'] }, followAlternate?: boolean): Promise {
+ const _followAlternate = followAlternate ?? true;
const keypair = await this.userKeypairService.getUserKeypair(user.id);
const req = ApRequestCreator.createSignedGet({
@@ -198,9 +200,29 @@ export class ApRequestService {
headers: req.request.headers,
}, {
throwErrorWhenResponseNotOk: true,
- validators: [validateContentTypeSetAsActivityPub],
});
+ //#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき
+ const contentType = res.headers.get('content-type');
+
+ if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate === true) {
+ const html = await res.text();
+ const window = new Window();
+ const document = window.document;
+ document.documentElement.innerHTML = html;
+
+ const alternate = document.querySelector('head > link[rel="alternate"][type="application/activity+json"]');
+ if (alternate) {
+ const href = alternate.getAttribute('href');
+ if (href) {
+ return await this.signedGet(href, user, false);
+ }
+ }
+ }
+ //#endregion
+
+ validateContentTypeSetAsActivityPub(res);
+
return await res.json();
}
}
diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
index 4074e416b8..01dea703a3 100644
--- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
+++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
@@ -7,9 +7,9 @@ import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { UsersRepository } from '@/models/_.js';
import { QueueService } from '@/core/QueueService.js';
-import { UserSuspendService } from '@/core/UserSuspendService.js';
import { DI } from '@/di-symbols.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
+import { DeleteAccountService } from '@/core/DeleteAccountService.js';
export const meta = {
tags: ['admin'],
@@ -33,9 +33,7 @@ export default class extends Endpoint { // eslint-
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
- private userEntityService: UserEntityService,
- private queueService: QueueService,
- private userSuspendService: UserSuspendService,
+ private deleteAccoountService: DeleteAccountService,
) {
super(meta, paramDef, async (ps, me) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
@@ -48,22 +46,7 @@ export default class extends Endpoint { // eslint-
throw new Error('cannot delete a root account');
}
- if (this.userEntityService.isLocalUser(user)) {
- // 物理削除する前にDelete activityを送信する
- await this.userSuspendService.doPostSuspend(user).catch(err => {});
-
- this.queueService.createDeleteAccountJob(user, {
- soft: false,
- });
- } else {
- this.queueService.createDeleteAccountJob(user, {
- soft: true, // リモートユーザーの削除は、完全にDBから物理削除してしまうと再度連合してきてアカウントが復活する可能性があるため、soft指定する
- });
- }
-
- await this.usersRepository.update(user.id, {
- isDeleted: true,
- });
+ await this.deleteAccoountService.deleteAccount(user);
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/admin/roles/update-default-policies.ts b/packages/backend/src/server/api/endpoints/admin/roles/update-default-policies.ts
index d7209965db..5cf49670be 100644
--- a/packages/backend/src/server/api/endpoints/admin/roles/update-default-policies.ts
+++ b/packages/backend/src/server/api/endpoints/admin/roles/update-default-policies.ts
@@ -7,6 +7,7 @@ import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { MetaService } from '@/core/MetaService.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
export const meta = {
tags: ['admin', 'role'],
@@ -33,12 +34,22 @@ export default class extends Endpoint { // eslint-
constructor(
private metaService: MetaService,
private globalEventService: GlobalEventService,
+ private moderationLogService: ModerationLogService,
) {
- super(meta, paramDef, async (ps) => {
+ super(meta, paramDef, async (ps, me) => {
+ const before = await this.metaService.fetch(true);
+
await this.metaService.update({
policies: ps.policies,
});
- this.globalEventService.publishInternalEvent('policiesUpdated', ps.policies);
+
+ const after = await this.metaService.fetch(true);
+
+ this.globalEventService.publishInternalEvent('policiesUpdated', after.policies);
+ this.moderationLogService.log(me, 'updateServerSettings', {
+ before: before.policies,
+ after: after.policies,
+ });
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
index 8a946405cc..bea1bdc4ed 100644
--- a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
@@ -3,18 +3,12 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-import { IsNull, Not } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
-import type { UsersRepository, FollowingsRepository } from '@/models/_.js';
-import type { MiUser } from '@/models/User.js';
-import type { RelationshipJobData } from '@/queue/types.js';
-import { ModerationLogService } from '@/core/ModerationLogService.js';
+import type { UsersRepository } from '@/models/_.js';
import { UserSuspendService } from '@/core/UserSuspendService.js';
import { DI } from '@/di-symbols.js';
-import { bindThis } from '@/decorators.js';
import { RoleService } from '@/core/RoleService.js';
-import { QueueService } from '@/core/QueueService.js';
export const meta = {
tags: ['admin'],
@@ -38,13 +32,8 @@ export default class extends Endpoint { // eslint-
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
- @Inject(DI.followingsRepository)
- private followingsRepository: FollowingsRepository,
-
private userSuspendService: UserSuspendService,
private roleService: RoleService,
- private moderationLogService: ModerationLogService,
- private queueService: QueueService,
) {
super(meta, paramDef, async (ps, me) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
@@ -57,42 +46,7 @@ export default class extends Endpoint { // eslint-
throw new Error('cannot suspend moderator account');
}
- await this.usersRepository.update(user.id, {
- isSuspended: true,
- });
-
- this.moderationLogService.log(me, 'suspend', {
- userId: user.id,
- userUsername: user.username,
- userHost: user.host,
- });
-
- (async () => {
- await this.userSuspendService.doPostSuspend(user).catch(e => {});
- await this.unFollowAll(user).catch(e => {});
- })();
+ await this.userSuspendService.suspend(user, me);
});
}
-
- @bindThis
- private async unFollowAll(follower: MiUser) {
- const followings = await this.followingsRepository.find({
- where: {
- followerId: follower.id,
- followeeId: Not(IsNull()),
- },
- });
-
- const jobs: RelationshipJobData[] = [];
- for (const following of followings) {
- if (following.followeeId && following.followerId) {
- jobs.push({
- from: { id: following.followerId },
- to: { id: following.followeeId },
- silent: true,
- });
- }
- }
- this.queueService.createUnfollowJob(jobs);
- }
}
diff --git a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
index 2c2b1bf6f5..b52c638cdb 100644
--- a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
@@ -6,7 +6,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { UsersRepository } from '@/models/_.js';
-import { ModerationLogService } from '@/core/ModerationLogService.js';
import { UserSuspendService } from '@/core/UserSuspendService.js';
import { DI } from '@/di-symbols.js';
@@ -33,7 +32,6 @@ export default class extends Endpoint { // eslint-
private usersRepository: UsersRepository,
private userSuspendService: UserSuspendService,
- private moderationLogService: ModerationLogService,
) {
super(meta, paramDef, async (ps, me) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
@@ -42,17 +40,7 @@ export default class extends Endpoint { // eslint-
throw new Error('user not found');
}
- await this.usersRepository.update(user.id, {
- isSuspended: false,
- });
-
- this.moderationLogService.log(me, 'unsuspend', {
- userId: user.id,
- userUsername: user.username,
- userHost: user.host,
- });
-
- this.userSuspendService.doPostUnsuspend(user);
+ await this.userSuspendService.unsuspend(user, me);
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/flash/delete.ts b/packages/backend/src/server/api/endpoints/flash/delete.ts
index d3d47e5deb..6912450abf 100644
--- a/packages/backend/src/server/api/endpoints/flash/delete.ts
+++ b/packages/backend/src/server/api/endpoints/flash/delete.ts
@@ -4,9 +4,11 @@
*/
import { Inject, Injectable } from '@nestjs/common';
-import type { FlashsRepository } from '@/models/_.js';
+import type { FlashsRepository, UsersRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
+import { RoleService } from '@/core/RoleService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -44,17 +46,35 @@ export default class extends Endpoint { // eslint-
constructor(
@Inject(DI.flashsRepository)
private flashsRepository: FlashsRepository,
+
+ @Inject(DI.usersRepository)
+ private usersRepository: UsersRepository,
+
+ private moderationLogService: ModerationLogService,
+ private roleService: RoleService,
) {
super(meta, paramDef, async (ps, me) => {
const flash = await this.flashsRepository.findOneBy({ id: ps.flashId });
+
if (flash == null) {
throw new ApiError(meta.errors.noSuchFlash);
}
- if (flash.userId !== me.id) {
+
+ if (!await this.roleService.isModerator(me) && flash.userId !== me.id) {
throw new ApiError(meta.errors.accessDenied);
}
await this.flashsRepository.delete(flash.id);
+
+ if (flash.userId !== me.id) {
+ const user = await this.usersRepository.findOneByOrFail({ id: flash.userId });
+ this.moderationLogService.log(me, 'deleteFlash', {
+ flashId: flash.id,
+ flashUserId: flash.userId,
+ flashUserUsername: user.username,
+ flash,
+ });
+ }
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
index 527e3fb52d..b6b94db161 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
@@ -5,8 +5,10 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
-import type { GalleryPostsRepository } from '@/models/_.js';
+import type { GalleryPostsRepository, UsersRepository } from '@/models/_.js';
import { DI } from '@/di-symbols.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
+import { RoleService } from '@/core/RoleService.js';
import { ApiError } from '../../../error.js';
export const meta = {
@@ -22,6 +24,12 @@ export const meta = {
code: 'NO_SUCH_POST',
id: 'ae52f367-4bd7-4ecd-afc6-5672fff427f5',
},
+
+ accessDenied: {
+ message: 'Access denied.',
+ code: 'ACCESS_DENIED',
+ id: 'c86e09de-1c48-43ac-a435-1c7e42ed4496',
+ },
},
} as const;
@@ -38,18 +46,35 @@ export default class extends Endpoint { // eslint-
constructor(
@Inject(DI.galleryPostsRepository)
private galleryPostsRepository: GalleryPostsRepository,
+
+ @Inject(DI.usersRepository)
+ private usersRepository: UsersRepository,
+
+ private moderationLogService: ModerationLogService,
+ private roleService: RoleService,
) {
super(meta, paramDef, async (ps, me) => {
- const post = await this.galleryPostsRepository.findOneBy({
- id: ps.postId,
- userId: me.id,
- });
+ const post = await this.galleryPostsRepository.findOneBy({ id: ps.postId });
if (post == null) {
throw new ApiError(meta.errors.noSuchPost);
}
+ if (!await this.roleService.isModerator(me) && post.userId !== me.id) {
+ throw new ApiError(meta.errors.accessDenied);
+ }
+
await this.galleryPostsRepository.delete(post.id);
+
+ if (post.userId !== me.id) {
+ const user = await this.usersRepository.findOneByOrFail({ id: post.userId });
+ this.moderationLogService.log(me, 'deleteGalleryPost', {
+ postId: post.id,
+ postUserId: post.userId,
+ postUserUsername: user.username,
+ post,
+ });
+ }
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/pages/delete.ts b/packages/backend/src/server/api/endpoints/pages/delete.ts
index aa2ba75a41..f2bc946788 100644
--- a/packages/backend/src/server/api/endpoints/pages/delete.ts
+++ b/packages/backend/src/server/api/endpoints/pages/delete.ts
@@ -4,9 +4,11 @@
*/
import { Inject, Injectable } from '@nestjs/common';
-import type { PagesRepository } from '@/models/_.js';
+import type { PagesRepository, UsersRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
+import { ModerationLogService } from '@/core/ModerationLogService.js';
+import { RoleService } from '@/core/RoleService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -44,17 +46,35 @@ export default class extends Endpoint { // eslint-
constructor(
@Inject(DI.pagesRepository)
private pagesRepository: PagesRepository,
+
+ @Inject(DI.usersRepository)
+ private usersRepository: UsersRepository,
+
+ private moderationLogService: ModerationLogService,
+ private roleService: RoleService,
) {
super(meta, paramDef, async (ps, me) => {
const page = await this.pagesRepository.findOneBy({ id: ps.pageId });
+
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
}
- if (page.userId !== me.id) {
+
+ if (!await this.roleService.isModerator(me) && page.userId !== me.id) {
throw new ApiError(meta.errors.accessDenied);
}
await this.pagesRepository.delete(page.id);
+
+ if (page.userId !== me.id) {
+ const user = await this.usersRepository.findOneByOrFail({ id: page.userId });
+ this.moderationLogService.log(me, 'deletePage', {
+ pageId: page.id,
+ pageUserId: page.userId,
+ pageUserUsername: user.username,
+ page,
+ });
+ }
});
}
}
diff --git a/packages/backend/src/server/api/stream/Connection.ts b/packages/backend/src/server/api/stream/Connection.ts
index 7773150b74..0fb5238c78 100644
--- a/packages/backend/src/server/api/stream/Connection.ts
+++ b/packages/backend/src/server/api/stream/Connection.ts
@@ -20,6 +20,8 @@ import type { ChannelsService } from './ChannelsService.js';
import type { EventEmitter } from 'events';
import type Channel from './channel.js';
+const MAX_CHANNELS_PER_CONNECTION = 32;
+
/**
* Main stream connection
*/
@@ -255,6 +257,10 @@ export default class Connection {
*/
@bindThis
public connectChannel(id: string, params: JsonObject | undefined, channel: string, pong = false) {
+ if (this.channels.length >= MAX_CHANNELS_PER_CONNECTION) {
+ return;
+ }
+
const channelService = this.channelsService.getChannelService(channel);
if (channelService.requireCredential && this.user == null) {
diff --git a/packages/backend/src/server/api/stream/channels/reversi-game.ts b/packages/backend/src/server/api/stream/channels/reversi-game.ts
index c6f4a4ae3b..7597a1cfa3 100644
--- a/packages/backend/src/server/api/stream/channels/reversi-game.ts
+++ b/packages/backend/src/server/api/stream/channels/reversi-game.ts
@@ -12,6 +12,7 @@ import { ReversiGameEntityService } from '@/core/entities/ReversiGameEntityServi
import { isJsonObject } from '@/misc/json-value.js';
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
import Channel, { type MiChannelService } from '../channel.js';
+import { reversiUpdateKeys } from 'misskey-js';
class ReversiGameChannel extends Channel {
public readonly chName = 'reversiGame';
@@ -46,8 +47,9 @@ class ReversiGameChannel extends Channel {
break;
case 'updateSettings':
if (!isJsonObject(body)) return;
- if (typeof body.key !== 'string') return;
- if (!isJsonObject(body.value)) return;
+ if (!this.reversiService.isValidReversiUpdateKey(body.key)) return;
+ if (!this.reversiService.isValidReversiUpdateValue(body.key, body.value)) return;
+
this.updateSettings(body.key, body.value);
break;
case 'cancel':
@@ -64,7 +66,7 @@ class ReversiGameChannel extends Channel {
}
@bindThis
- private async updateSettings(key: string, value: JsonObject) {
+ private async updateSettings(key: K, value: MiReversiGame[K]) {
if (this.user == null) return;
this.reversiService.updateSettings(this.gameId!, this.user, key, value);
diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts
index ba2d05d581..e9b1aed7d4 100644
--- a/packages/backend/src/types.ts
+++ b/packages/backend/src/types.ts
@@ -97,6 +97,10 @@ export const moderationLogTypes = [
'createAbuseReportNotificationRecipient',
'updateAbuseReportNotificationRecipient',
'deleteAbuseReportNotificationRecipient',
+ 'deleteAccount',
+ 'deletePage',
+ 'deleteFlash',
+ 'deleteGalleryPost',
] as const;
export type ModerationLogPayloads = {
@@ -323,6 +327,29 @@ export type ModerationLogPayloads = {
recipientId: string;
recipient: any;
};
+ deleteAccount: {
+ userId: string;
+ userUsername: string;
+ userHost: string | null;
+ };
+ deletePage: {
+ pageId: string;
+ pageUserId: string;
+ pageUserUsername: string;
+ page: any;
+ };
+ deleteFlash: {
+ flashId: string;
+ flashUserId: string;
+ flashUserUsername: string;
+ flash: any;
+ };
+ deleteGalleryPost: {
+ postId: string;
+ postUserId: string;
+ postUserUsername: string;
+ post: any;
+ };
};
export type Serialized = {
diff --git a/packages/frontend/src/components/MkAbuseReportWindow.vue b/packages/frontend/src/components/MkAbuseReportWindow.vue
index b09c7bb3fb..a634a748e9 100644
--- a/packages/frontend/src/components/MkAbuseReportWindow.vue
+++ b/packages/frontend/src/components/MkAbuseReportWindow.vue
@@ -39,7 +39,7 @@ import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
- user: Misskey.entities.UserDetailed;
+ user: Misskey.entities.UserLite;
initialComment?: string;
}>();
diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue
index 13273a53b4..32d1cc5640 100644
--- a/packages/frontend/src/components/MkNote.vue
+++ b/packages/frontend/src/components/MkNote.vue
@@ -200,6 +200,7 @@ import { host } from '@/config.js';
import { isEnabledUrlPreview } from '@/instance.js';
import { type Keymap } from '@/scripts/hotkey.js';
import { focusPrev, focusNext } from '@/scripts/focus.js';
+import { getAppearNote } from '@/scripts/get-appear-note.js';
const props = withDefaults(defineProps<{
note: Misskey.entities.Note;
@@ -242,14 +243,7 @@ if (noteViewInterruptors.length > 0) {
});
}
-const isRenote = (
- note.value.renote != null &&
- note.value.reply == null &&
- note.value.text == null &&
- note.value.cw == null &&
- note.value.fileIds && note.value.fileIds.length === 0 &&
- note.value.poll == null
-);
+const isRenote = Misskey.note.isPureRenote(note.value);
const rootEl = shallowRef();
const menuButton = shallowRef();
@@ -257,7 +251,7 @@ const renoteButton = shallowRef();
const renoteTime = shallowRef();
const reactButton = shallowRef();
const clipButton = shallowRef();
-const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entities.Note : note.value);
+const appearNote = computed(() => getAppearNote(note.value));
const galleryEl = shallowRef>();
const isMyRenote = $i && ($i.id === note.value.userId);
const showContent = ref(false);
diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue
index c47334feda..c228c1298e 100644
--- a/packages/frontend/src/components/MkNoteDetailed.vue
+++ b/packages/frontend/src/components/MkNoteDetailed.vue
@@ -232,6 +232,7 @@ import MkPagination, { type Paging } from '@/components/MkPagination.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue';
import MkButton from '@/components/MkButton.vue';
import { isEnabledUrlPreview } from '@/instance.js';
+import { getAppearNote } from '@/scripts/get-appear-note.js';
import { type Keymap } from '@/scripts/hotkey.js';
const props = withDefaults(defineProps<{
@@ -264,14 +265,7 @@ if (noteViewInterruptors.length > 0) {
});
}
-const isRenote = (
- note.value.renote != null &&
- note.value.reply == null &&
- note.value.text == null &&
- note.value.cw == null &&
- note.value.fileIds && note.value.fileIds.length === 0 &&
- note.value.poll == null
-);
+const isRenote = Misskey.note.isPureRenote(note.value);
const rootEl = shallowRef();
const menuButton = shallowRef();
@@ -279,7 +273,7 @@ const renoteButton = shallowRef();
const renoteTime = shallowRef();
const reactButton = shallowRef();
const clipButton = shallowRef();
-const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entities.Note : note.value);
+const appearNote = computed(() => getAppearNote(note.value));
const galleryEl = shallowRef>();
const isMyRenote = $i && ($i.id === note.value.userId);
const showContent = ref(false);
diff --git a/packages/frontend/src/components/MkRolePreview.vue b/packages/frontend/src/components/MkRolePreview.vue
index c1b922198f..ef9fa531aa 100644
--- a/packages/frontend/src/components/MkRolePreview.vue
+++ b/packages/frontend/src/components/MkRolePreview.vue
@@ -4,25 +4,32 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ role.name }}
+
+ {{ role.usersCount }} users
+ ({{ i18n.ts._role.conditional }})
-
-
-
-
-
-
-
{{ role.name }}
-
- {{ role.usersCount }} users
- ({{ i18n.ts._role.conditional }})
-
+
+
{{ role.description }}
- {{ role.description }}
@@ -42,34 +49,44 @@ const props = withDefaults(defineProps<{