From f1889d3c5ba58aa22f49b7da9e3d5d54eae304ba Mon Sep 17 00:00:00 2001 From: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Date: Sat, 17 Jun 2023 13:01:22 +0900 Subject: [PATCH 001/525] =?UTF-8?q?feat:=20=E9=80=9A=E5=A0=B1=E3=81=AE?= =?UTF-8?q?=E5=8D=B3=E6=99=82=E8=A7=A3=E6=B1=BA=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 19 ++ locales/ja-JP.yml | 18 ++ .../1686908762393-AbuseReportResolver.js | 19 ++ packages/backend/src/core/QueueService.ts | 6 + packages/backend/src/di-symbols.ts | 1 + .../backend/src/models/RepositoryModule.ts | 10 +- .../models/entities/AbuseReportResolver.ts | 58 ++++++ packages/backend/src/models/index.ts | 3 + packages/backend/src/postgres.ts | 2 + .../backend/src/queue/QueueProcessorModule.ts | 2 + .../src/queue/QueueProcessorService.ts | 3 + .../processors/ReportAbuseProcessorService.ts | 112 ++++++++++++ packages/backend/src/queue/types.ts | 3 + .../backend/src/server/api/EndpointsModule.ts | 16 ++ packages/backend/src/server/api/endpoints.ts | 8 + .../admin/abuse-report-resolver/create.ts | 135 ++++++++++++++ .../admin/abuse-report-resolver/delete.ts | 47 +++++ .../admin/abuse-report-resolver/list.ts | 77 ++++++++ .../admin/abuse-report-resolver/update.ts | 110 +++++++++++ .../api/endpoints/users/report-abuse.ts | 30 +-- .../src/components/MkAbuseReportResolver.vue | 145 +++++++++++++++ packages/frontend/src/components/MkFolder.vue | 4 + packages/frontend/src/components/MkInput.vue | 8 +- packages/frontend/src/components/MkSelect.vue | 6 +- packages/frontend/src/pages/admin/abuses.vue | 171 +++++++++++++++++- packages/misskey-js/etc/misskey-js.api.md | 18 +- packages/misskey-js/src/api.types.ts | 4 + 27 files changed, 993 insertions(+), 42 deletions(-) create mode 100644 packages/backend/migration/1686908762393-AbuseReportResolver.js create mode 100644 packages/backend/src/models/entities/AbuseReportResolver.ts create mode 100644 packages/backend/src/queue/processors/ReportAbuseProcessorService.ts create mode 100644 packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts create mode 100644 packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/delete.ts create mode 100644 packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/list.ts create mode 100644 packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts create mode 100644 packages/frontend/src/components/MkAbuseReportResolver.vue diff --git a/locales/index.d.ts b/locales/index.d.ts index eed29f408c..7b8dccaee5 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2144,6 +2144,25 @@ export interface Locale { "mention": string; }; }; + "_abuse": { + "_resolver": { + "1hour": string; + "12hours": string; + "1day": string; + "1week": string; + "1month": string; + "3months": string; + "6months": string; + "1year": string; + "indefinitely": string; + "expiresAt": string; + "targetUserPattern": string; + "reporterPattern": string; + "reportContentPattern": string; + "list": string; + "resolver": string; + }; + }; } declare const locales: { [lang: string]: Locale; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 8004e53575..0a2f8eec10 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2057,3 +2057,21 @@ _webhookSettings: renote: "Renoteされたとき" reaction: "リアクションがあったとき" mention: "メンションされたとき" + +_abuse: + _resolver: + 1hour: "一時間" + 12hours: "半日" + 1day: "一日" + 1week: "一週間" + 1month: "一ヶ月" + 3months: "三ヶ月" + 6months: "六ヶ月" + 1year: "一年" + indefinitely: "無期限" + expiresAt: "この条件の有効期限" + targetUserPattern: "通報先のパターン" + reporterPattern: "通報元のパターン" + reportContentPattern: "通報内容のパターン" + list: "一覧" + resolver: "リソルバー" diff --git a/packages/backend/migration/1686908762393-AbuseReportResolver.js b/packages/backend/migration/1686908762393-AbuseReportResolver.js new file mode 100644 index 0000000000..2550a7c1f3 --- /dev/null +++ b/packages/backend/migration/1686908762393-AbuseReportResolver.js @@ -0,0 +1,19 @@ +export class AbuseReportResolver1686908762393 { + name = 'AbuseReportResolver1686908762393' + + async up(queryRunner) { + await queryRunner.query(`CREATE TYPE "public"."abuse_report_resolver_expiresat_enum" AS ENUM('1hour', '12hours', '1day', '1week', '1month', '3months', '6months', '1year', 'indefinitely')`); + await queryRunner.query(`CREATE TABLE "abuse_report_resolver" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "name" character varying(256) NOT NULL, "targetUserPattern" character varying(1024), "reporterPattern" character varying(1024), "reportContentPattern" character varying(1024), "expirationDate" TIMESTAMP WITH TIME ZONE, "expiresAt" "public"."abuse_report_resolver_expiresat_enum" NOT NULL, "forward" boolean NOT NULL, CONSTRAINT "PK_093500bf1bb38880d38b1bb41dc" PRIMARY KEY ("id")); COMMENT ON COLUMN "abuse_report_resolver"."createdAt" IS 'The created date of AbuseReportResolver'; COMMENT ON COLUMN "abuse_report_resolver"."updatedAt" IS 'The updated date of AbuseReportResolver'; COMMENT ON COLUMN "abuse_report_resolver"."expirationDate" IS 'The expiration date of AbuseReportResolver'`); + await queryRunner.query(`CREATE INDEX "IDX_fdd74ab625ed0f6a30c47b00e0" ON "abuse_report_resolver" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_d90c2c0e555b1eb2e4f19c9ad4" ON "abuse_report_resolver" ("updatedAt") `); + await queryRunner.query(`CREATE INDEX "IDX_e83a32a146021c72ba9bde6675" ON "abuse_report_resolver" ("expirationDate") `); + } + + async down(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_e83a32a146021c72ba9bde6675"`); + await queryRunner.query(`DROP INDEX "public"."IDX_d90c2c0e555b1eb2e4f19c9ad4"`); + await queryRunner.query(`DROP INDEX "public"."IDX_fdd74ab625ed0f6a30c47b00e0"`); + await queryRunner.query(`DROP TABLE "abuse_report_resolver"`); + await queryRunner.query(`DROP TYPE "public"."abuse_report_resolver_expiresat_enum"`); + } +} diff --git a/packages/backend/src/core/QueueService.ts b/packages/backend/src/core/QueueService.ts index 2ae8a2b754..467e9851f6 100644 --- a/packages/backend/src/core/QueueService.ts +++ b/packages/backend/src/core/QueueService.ts @@ -2,6 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { v4 as uuid } from 'uuid'; import type { IActivity } from '@/core/activitypub/type.js'; import type { DriveFile } from '@/models/entities/DriveFile.js'; +import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js'; import type { Webhook, webhookEventTypes } from '@/models/entities/Webhook.js'; import type { Config } from '@/config.js'; import { DI } from '@/di-symbols.js'; @@ -302,6 +303,11 @@ export class QueueService { }); } + @bindThis + public createReportAbuseJob(report: AbuseUserReport) { + return this.dbQueue.add('reportAbuse', report); + } + @bindThis public createFollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string, silent?: boolean }[]) { const jobs = followings.map(rel => this.generateRelationshipJobData('follow', rel)); diff --git a/packages/backend/src/di-symbols.ts b/packages/backend/src/di-symbols.ts index 4a073f102f..d80677548a 100644 --- a/packages/backend/src/di-symbols.ts +++ b/packages/backend/src/di-symbols.ts @@ -9,6 +9,7 @@ export const DI = { //#region Repositories usersRepository: Symbol('usersRepository'), notesRepository: Symbol('notesRepository'), + abuseReportResolversRepository: Symbol('abuseReportResolversRepository'), announcementsRepository: Symbol('announcementsRepository'), announcementReadsRepository: Symbol('announcementReadsRepository'), appsRepository: Symbol('appsRepository'), diff --git a/packages/backend/src/models/RepositoryModule.ts b/packages/backend/src/models/RepositoryModule.ts index 4231acc046..7040196ee6 100644 --- a/packages/backend/src/models/RepositoryModule.ts +++ b/packages/backend/src/models/RepositoryModule.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite, UserMemo, UserListFavorite } from './index.js'; +import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite, UserMemo, UserListFavorite, AbuseReportResolver } from './index.js'; import type { DataSource } from 'typeorm'; import type { Provider } from '@nestjs/common'; @@ -400,6 +400,12 @@ const $userMemosRepository: Provider = { inject: [DI.db], }; +const $abuseReportResolversRepository: Provider = { + provide: DI.abuseReportResolversRepository, + useFactory: (db: DataSource) => db.getRepository(AbuseReportResolver), + inject: [DI.db], +}; + @Module({ imports: [ ], @@ -470,6 +476,7 @@ const $userMemosRepository: Provider = { $flashsRepository, $flashLikesRepository, $userMemosRepository, + $abuseReportResolversRepository, ], exports: [ $usersRepository, @@ -538,6 +545,7 @@ const $userMemosRepository: Provider = { $flashsRepository, $flashLikesRepository, $userMemosRepository, + $abuseReportResolversRepository, ], }) export class RepositoryModule {} diff --git a/packages/backend/src/models/entities/AbuseReportResolver.ts b/packages/backend/src/models/entities/AbuseReportResolver.ts new file mode 100644 index 0000000000..0299caf33c --- /dev/null +++ b/packages/backend/src/models/entities/AbuseReportResolver.ts @@ -0,0 +1,58 @@ +import { Column, Entity, PrimaryColumn, Index } from 'typeorm'; +import { id } from '../id.js'; + +@Entity() +export class AbuseReportResolver { + @PrimaryColumn(id()) + public id: string; + + @Index() + @Column('timestamp with time zone', { + comment: 'The created date of AbuseReportResolver', + }) + public createdAt: Date; + + @Index() + @Column('timestamp with time zone', { + comment: 'The updated date of AbuseReportResolver', + }) + public updatedAt: Date; + + @Column('varchar', { + length: 256, + }) + public name: string; + + @Column('varchar', { + length: 1024, + nullable: true, + }) + public targetUserPattern: string | null; + + @Column('varchar', { + length: 1024, + nullable: true, + }) + public reporterPattern: string | null; + + @Column('varchar', { + length: 1024, + nullable: true, + }) + public reportContentPattern: string | null; + + @Index() + @Column('timestamp with time zone', { + comment: 'The expiration date of AbuseReportResolver', + nullable: true, + }) + public expirationDate: Date | null; + + @Column('enum', { + enum: ['1hour', '12hours', '1day', '1week', '1month', '3months', '6months', '1year', 'indefinitely'] + }) + public expiresAt: string; + + @Column('boolean') + public forward: boolean; +} diff --git a/packages/backend/src/models/index.ts b/packages/backend/src/models/index.ts index 4b230ab742..72cb840bb2 100644 --- a/packages/backend/src/models/index.ts +++ b/packages/backend/src/models/index.ts @@ -1,3 +1,4 @@ +import { AbuseReportResolver } from '@/models/entities/AbuseReportResolver.js'; import { AbuseUserReport } from '@/models/entities/AbuseUserReport.js'; import { AccessToken } from '@/models/entities/AccessToken.js'; import { Ad } from '@/models/entities/Ad.js'; @@ -67,6 +68,7 @@ import { FlashLike } from '@/models/entities/FlashLike.js'; import type { Repository } from 'typeorm'; export { + AbuseReportResolver, AbuseUserReport, AccessToken, Ad, @@ -135,6 +137,7 @@ export { UserMemo, }; +export type AbuseReportResolversRepository = Repository; export type AbuseUserReportsRepository = Repository; export type AccessTokensRepository = Repository; export type AdsRepository = Repository; diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index 488979c409..b3ac33cb23 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -6,6 +6,7 @@ import { DataSource, Logger } from 'typeorm'; import * as highlight from 'cli-highlight'; import { entities as charts } from '@/core/chart/entities.js'; +import { AbuseReportResolver } from '@/models/entities/AbuseReportResolver.js'; import { AbuseUserReport } from '@/models/entities/AbuseUserReport.js'; import { AccessToken } from '@/models/entities/AccessToken.js'; import { Ad } from '@/models/entities/Ad.js'; @@ -121,6 +122,7 @@ class MyCustomLogger implements Logger { } export const entities = [ + AbuseReportResolver, Announcement, AnnouncementRead, Meta, diff --git a/packages/backend/src/queue/QueueProcessorModule.ts b/packages/backend/src/queue/QueueProcessorModule.ts index e1c6b93d9b..c3c84ddb4c 100644 --- a/packages/backend/src/queue/QueueProcessorModule.ts +++ b/packages/backend/src/queue/QueueProcessorModule.ts @@ -28,6 +28,7 @@ import { ImportMutingProcessorService } from './processors/ImportMutingProcessor import { ImportUserListsProcessorService } from './processors/ImportUserListsProcessorService.js'; import { ImportAntennasProcessorService } from './processors/ImportAntennasProcessorService.js'; import { ResyncChartsProcessorService } from './processors/ResyncChartsProcessorService.js'; +import { ReportAbuseProcessorService } from './processors/ReportAbuseProcessorService.js'; import { TickChartsProcessorService } from './processors/TickChartsProcessorService.js'; import { AggregateRetentionProcessorService } from './processors/AggregateRetentionProcessorService.js'; import { ExportFavoritesProcessorService } from './processors/ExportFavoritesProcessorService.js'; @@ -64,6 +65,7 @@ import { RelationshipProcessorService } from './processors/RelationshipProcessor DeleteFileProcessorService, CleanRemoteFilesProcessorService, RelationshipProcessorService, + ReportAbuseProcessorService, WebhookDeliverProcessorService, EndedPollNotificationProcessorService, DeliverProcessorService, diff --git a/packages/backend/src/queue/QueueProcessorService.ts b/packages/backend/src/queue/QueueProcessorService.ts index 42f9c1af7d..cb5c332abe 100644 --- a/packages/backend/src/queue/QueueProcessorService.ts +++ b/packages/backend/src/queue/QueueProcessorService.ts @@ -27,6 +27,7 @@ import { ExportFavoritesProcessorService } from './processors/ExportFavoritesPro import { CleanRemoteFilesProcessorService } from './processors/CleanRemoteFilesProcessorService.js'; import { DeleteFileProcessorService } from './processors/DeleteFileProcessorService.js'; import { RelationshipProcessorService } from './processors/RelationshipProcessorService.js'; +import { ReportAbuseProcessorService } from './processors/ReportAbuseProcessorService.js'; import { TickChartsProcessorService } from './processors/TickChartsProcessorService.js'; import { ResyncChartsProcessorService } from './processors/ResyncChartsProcessorService.js'; import { CleanChartsProcessorService } from './processors/CleanChartsProcessorService.js'; @@ -102,6 +103,7 @@ export class QueueProcessorService implements OnApplicationShutdown { private deleteFileProcessorService: DeleteFileProcessorService, private cleanRemoteFilesProcessorService: CleanRemoteFilesProcessorService, private relationshipProcessorService: RelationshipProcessorService, + private reportAbuseProcessorService: ReportAbuseProcessorService, private tickChartsProcessorService: TickChartsProcessorService, private resyncChartsProcessorService: ResyncChartsProcessorService, private cleanChartsProcessorService: CleanChartsProcessorService, @@ -174,6 +176,7 @@ export class QueueProcessorService implements OnApplicationShutdown { case 'importCustomEmojis': return this.importCustomEmojisProcessorService.process(job); case 'importAntennas': return this.importAntennasProcessorService.process(job); case 'deleteAccount': return this.deleteAccountProcessorService.process(job); + case 'reportAbuse': return this.reportAbuseProcessorService.process(job); default: throw new Error(`unrecognized job type ${job.name} for db`); } }, { diff --git a/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts b/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts new file mode 100644 index 0000000000..f66601918a --- /dev/null +++ b/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts @@ -0,0 +1,112 @@ +import { Injectable, Inject } from '@nestjs/common'; +import { MoreThan, IsNull } from 'typeorm'; +import RE2 from 're2'; +import * as sanitizeHtml from 'sanitize-html'; +import { bindThis } from '@/decorators.js'; +import type Logger from '@/logger.js'; +import { RoleService } from '@/core/RoleService.js'; +import { MetaService } from '@/core/MetaService.js'; +import { EmailService } from '@/core/EmailService.js'; +import { GlobalEventService } from '@/core/GlobalEventService.js'; +import { InstanceActorService } from '@/core/InstanceActorService.js'; +import type { AbuseReportResolversRepository, AbuseUserReportsRepository, UsersRepository } from '@/models/index.js'; +import { DI } from '@/di-symbols.js'; +import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; +import { QueueService } from '@/core/QueueService.js'; +import { QueueLoggerService } from '../QueueLoggerService.js'; +import type { DbAbuseReportJobData } from '../types.js'; +import type * as Bull from 'bullmq'; + +@Injectable() +export class ReportAbuseProcessorService { + private logger: Logger; + + constructor( + @Inject(DI.abuseReportResolversRepository) + private abuseReportResolversRepository: AbuseReportResolversRepository, + + @Inject(DI.abuseUserReportsRepository) + private abuseUserReportsRepository: AbuseUserReportsRepository, + + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + + private queueLoggerService: QueueLoggerService, + private globalEventService: GlobalEventService, + private instanceActorService: InstanceActorService, + private apRendererService: ApRendererService, + private roleService: RoleService, + private metaService: MetaService, + private emailService: EmailService, + private queueService: QueueService, + ) { + this.logger = this.queueLoggerService.logger.createSubLogger('report-abuse'); + } + + @bindThis + public async process(job: Bull.Job): Promise { + this.logger.info('Running...'); + + const resolvers = await this.abuseReportResolversRepository.find({ + where: [ + { expirationDate: MoreThan(new Date()) }, + { expirationDate: IsNull() }, + ], + }); + + const targetUser = await this.usersRepository.findOneByOrFail({ + id: job.data.targetUserId, + }); + + const reporter = await this.usersRepository.findOneByOrFail({ + id: job.data.reporterId, + }); + + const actor = await this.instanceActorService.getInstanceActor(); + + const targetUserAcct = targetUser.host ? `${targetUser.username.toLowerCase()}@${targetUser.host}` : targetUser.username.toLowerCase(); + const reporterAcct = reporter.host ? `${reporter.username.toLowerCase()}@${reporter.host}` : reporter.username.toLowerCase(); + + for (const resolver of resolvers) { + const isTargetUserPatternMatched = resolver.targetUserPattern ? new RE2(resolver.targetUserPattern).test(targetUserAcct) : false; + const isReporterPatternMatched = resolver.reporterPattern ? new RE2(resolver.reporterPattern).test(reporterAcct) : false; + const isReportContentPatternMatched = resolver.reportContentPattern ? new RE2(resolver.reportContentPattern).test(job.data.comment) : false; + + if (isTargetUserPatternMatched || isReporterPatternMatched || isReportContentPatternMatched) { + if (resolver.forward && job.data.targetUserHost !== null) { + const targetUser = await this.usersRepository.findOneByOrFail({ id: job.data.targetUserId }); + this.queueService.deliver(actor, this.apRendererService.addContext(this.apRendererService.renderFlag(actor, targetUser.uri!, job.data.comment)), targetUser.inbox, false); + } + + await this.abuseUserReportsRepository.update(job.data.id, { + resolved: true, + assigneeId: actor.id, + forwarded: resolver.forward && job.data.targetUserHost !== null, + }); + + return; + } + } + + // Publish event to moderators + setImmediate(async () => { + const moderators = await this.roleService.getModerators(); + + for (const moderator of moderators) { + this.globalEventService.publishAdminStream(moderator.id, 'newAbuseUserReport', { + id: job.data.id, + targetUserId: job.data.targetUserId, + reporterId: job.data.reporterId, + comment: job.data.comment, + }); + } + + const meta = await this.metaService.fetch(); + if (meta.email) { + this.emailService.sendEmail(meta.email, 'New abuse report', + sanitizeHtml(job.data.comment), + sanitizeHtml(job.data.comment)); + } + }); + } +} diff --git a/packages/backend/src/queue/types.ts b/packages/backend/src/queue/types.ts index 776dd3aa12..c44eec6ada 100644 --- a/packages/backend/src/queue/types.ts +++ b/packages/backend/src/queue/types.ts @@ -2,6 +2,7 @@ import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js'; import type { DriveFile } from '@/models/entities/DriveFile.js'; import type { Note } from '@/models/entities/Note.js'; import type { User } from '@/models/entities/User.js'; +import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js'; import type { Webhook } from '@/models/entities/Webhook.js'; import type { IActivity } from '@/core/activitypub/type.js'; import type httpSignature from '@peertube/http-signature'; @@ -86,6 +87,8 @@ export type DbUserImportToDbJobData = { target: string; }; +export type DbAbuseReportJobData = AbuseUserReport; + export type ObjectStorageJobData = ObjectStorageFileJobData | Record; export type ObjectStorageFileJobData = { diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 1e32e9988d..9b7c992ea4 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -13,6 +13,10 @@ import * as ep___admin_announcements_create from './endpoints/admin/announcement import * as ep___admin_announcements_delete from './endpoints/admin/announcements/delete.js'; import * as ep___admin_announcements_list from './endpoints/admin/announcements/list.js'; import * as ep___admin_announcements_update from './endpoints/admin/announcements/update.js'; +import * as ep___admin_abuseReportResolver_create from './endpoints/admin/abuse-report-resolver/create.js'; +import * as ep___admin_abuseReportResolver_update from './endpoints/admin/abuse-report-resolver/update.js'; +import * as ep___admin_abuseReportResolver_delete from './endpoints/admin/abuse-report-resolver/delete.js'; +import * as ep___admin_abuseReportResolver_list from './endpoints/admin/abuse-report-resolver/list.js'; import * as ep___admin_deleteAllFilesOfAUser from './endpoints/admin/delete-all-files-of-a-user.js'; import * as ep___admin_drive_cleanRemoteFiles from './endpoints/admin/drive/clean-remote-files.js'; import * as ep___admin_drive_cleanup from './endpoints/admin/drive/cleanup.js'; @@ -354,6 +358,10 @@ const $admin_announcements_create: Provider = { provide: 'ep:admin/announcements const $admin_announcements_delete: Provider = { provide: 'ep:admin/announcements/delete', useClass: ep___admin_announcements_delete.default }; const $admin_announcements_list: Provider = { provide: 'ep:admin/announcements/list', useClass: ep___admin_announcements_list.default }; const $admin_announcements_update: Provider = { provide: 'ep:admin/announcements/update', useClass: ep___admin_announcements_update.default }; +const $admin_abuseReportResolver_create: Provider = { provide: 'ep:admin/abuse-report-resolver/create', useClass: ep___admin_abuseReportResolver_create.default }; +const $admin_abuseReportResolver_update: Provider = { provide: 'ep:admin/abuse-report-resolver/update', useClass: ep___admin_abuseReportResolver_update.default }; +const $admin_abuseReportResolver_list: Provider = { provide: 'ep:admin/abuse-report-resolver/list', useClass: ep___admin_abuseReportResolver_list.default }; +const $admin_abuseReportResolver_delete: Provider = { provide: 'ep:admin/abuse-report-resolver/delete', useClass: ep___admin_abuseReportResolver_delete.default }; const $admin_deleteAllFilesOfAUser: Provider = { provide: 'ep:admin/delete-all-files-of-a-user', useClass: ep___admin_deleteAllFilesOfAUser.default }; const $admin_drive_cleanRemoteFiles: Provider = { provide: 'ep:admin/drive/clean-remote-files', useClass: ep___admin_drive_cleanRemoteFiles.default }; const $admin_drive_cleanup: Provider = { provide: 'ep:admin/drive/cleanup', useClass: ep___admin_drive_cleanup.default }; @@ -699,6 +707,10 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $admin_announcements_delete, $admin_announcements_list, $admin_announcements_update, + $admin_abuseReportResolver_create, + $admin_abuseReportResolver_delete, + $admin_abuseReportResolver_list, + $admin_abuseReportResolver_update, $admin_deleteAllFilesOfAUser, $admin_drive_cleanRemoteFiles, $admin_drive_cleanup, @@ -1038,6 +1050,10 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $admin_announcements_delete, $admin_announcements_list, $admin_announcements_update, + $admin_abuseReportResolver_create, + $admin_abuseReportResolver_delete, + $admin_abuseReportResolver_list, + $admin_abuseReportResolver_update, $admin_deleteAllFilesOfAUser, $admin_drive_cleanRemoteFiles, $admin_drive_cleanup, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 7e678a6404..322d923c85 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -13,6 +13,10 @@ import * as ep___admin_announcements_create from './endpoints/admin/announcement import * as ep___admin_announcements_delete from './endpoints/admin/announcements/delete.js'; import * as ep___admin_announcements_list from './endpoints/admin/announcements/list.js'; import * as ep___admin_announcements_update from './endpoints/admin/announcements/update.js'; +import * as ep___admin_abuseReportResolver_create from './endpoints/admin/abuse-report-resolver/create.js'; +import * as ep___admin_abuseReportResolver_update from './endpoints/admin/abuse-report-resolver/update.js'; +import * as ep___admin_abuseReportResolver_delete from './endpoints/admin/abuse-report-resolver/delete.js'; +import * as ep___admin_abuseReportResolver_list from './endpoints/admin/abuse-report-resolver/list.js'; import * as ep___admin_deleteAllFilesOfAUser from './endpoints/admin/delete-all-files-of-a-user.js'; import * as ep___admin_drive_cleanRemoteFiles from './endpoints/admin/drive/clean-remote-files.js'; import * as ep___admin_drive_cleanup from './endpoints/admin/drive/cleanup.js'; @@ -352,6 +356,10 @@ const eps = [ ['admin/announcements/delete', ep___admin_announcements_delete], ['admin/announcements/list', ep___admin_announcements_list], ['admin/announcements/update', ep___admin_announcements_update], + ['admin/abuse-report-resolver/create', ep___admin_abuseReportResolver_create], + ['admin/abuse-report-resolver/list', ep___admin_abuseReportResolver_list], + ['admin/abuse-report-resolver/delete', ep___admin_abuseReportResolver_delete], + ['admin/abuse-report-resolver/update', ep___admin_abuseReportResolver_update], ['admin/delete-all-files-of-a-user', ep___admin_deleteAllFilesOfAUser], ['admin/drive/clean-remote-files', ep___admin_drive_cleanRemoteFiles], ['admin/drive/cleanup', ep___admin_drive_cleanup], diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts new file mode 100644 index 0000000000..cd0b0350a8 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts @@ -0,0 +1,135 @@ +import { Injectable, Inject } from '@nestjs/common'; +import ms from 'ms'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { DI } from '@/di-symbols.js'; +import { ApiError } from '@/server/api/error.js'; +import type { AbuseReportResolversRepository } from '@/models/index.js'; +import { IdService } from '@/core/IdService.js'; + +export const meta = { + tags: ['admin'], + + requireCredential: true, + + requireAdmin: true, + + res: { + type: 'object', + properties: { + name: { + type: 'string', + nullable: false, optional: false, + }, + targetUserPattern: { + type: 'string', + nullable: true, optional: false, + }, + reporterPattern: { + type: 'string', + nullable: true, optional: false, + }, + reportContentPattern: { + type: 'string', + nullable: true, optional: false, + }, + expiresAt: { + type: 'string', + nullable: false, optional: false, + }, + forward: { + type: 'boolean', + nullable: false, optional: false, + }, + }, + }, + + errors: { + invalidRegularExpressionForTargetUser: { + message: 'Invalid regular expression for target user.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_TARGET_USER', + id: 'c008484a-0a14-4e74-86f4-b176dc49fcaa', + }, + invalidRegularExpressionForReporter: { + message: 'Invalid regular expression for reporter.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_REPORTER', + id: '399b4062-257f-44c8-87cc-4ffae2527fbc', + }, + invalidRegularExpressionForReportContent: { + message: 'Invalid regular expression for report content.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_REPORT_CONTENT', + id: '88c124d8-f517-4c63-a464-0abc274168b', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + name: { type: 'string', minLength: 1 }, + targetUserPattern: { type: 'string', nullable: true }, + reporterPattern: { type: 'string', nullable: true }, + reportContentPattern: { type: 'string', nullable: true }, + expiresAt: { type: 'string', enum: ['1hour', '12hours', '1day', '1week', '1month', '3months', '6months', '1year', 'indefinitely'] }, + forward: { type: 'boolean' }, + }, + required: ['name', 'targetUserPattern', 'reporterPattern', 'reportContentPattern', 'expiresAt', 'forward'], +} as const; + +@Injectable() // eslint-disable-next-line import/no-default-export +export default class extends Endpoint { + constructor( + @Inject(DI.abuseReportResolversRepository) + private abuseReportResolverRepository: AbuseReportResolversRepository, + + private idService: IdService, + ) { + super(meta, paramDef, async (ps, me) => { + if (ps.targetUserPattern) { + try { + new RegExp(ps.targetUserPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForTargetUser); + } + } + if (ps.reporterPattern) { + try { + new RegExp(ps.reporterPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForReporter); + } + } + if (ps.reportContentPattern) { + try { + new RegExp(ps.reportContentPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForReportContent); + } + } + const now = new Date(); + let expirationDate: Date | null = new Date(); + + (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : + ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : + ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : + ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : + ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1) / 12))); } : + ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3) / 12))); } : + ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6) / 12))); } : + ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); + + return await this.abuseReportResolverRepository.insert({ + id: this.idService.genId(), + createdAt: now, + updatedAt: now, + name: ps.name, + targetUserPattern: ps.targetUserPattern, + reporterPattern: ps.reporterPattern, + reportContentPattern: ps.reportContentPattern, + expirationDate, + expiresAt: ps.expiresAt, + forward: ps.forward, + }).then(x => this.abuseReportResolverRepository.findOneByOrFail(x.identifiers[0])); + }); + } +} + diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/delete.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/delete.ts new file mode 100644 index 0000000000..b5829c41c8 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/delete.ts @@ -0,0 +1,47 @@ +import { Injectable, Inject } from '@nestjs/common'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { DI } from '@/di-symbols.js'; +import type { AbuseReportResolversRepository } from '@/models/index.js'; +import { ApiError } from '../../../error.js'; + +export const meta = { + requireCrendential: true, + + requireAdmin: true, + + errors: { + resolverNotFound: { + message: 'Resolver not found.', + code: 'RESOLVER_NOT_FOUND', + id: '121fbea9-3e49-4456-998a-d4095c7ac5c5', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + resolverId: { type: 'string', format: 'misskey:id' }, + }, + required: ['resolverId'], +} as const; + +@Injectable() // eslint-disable-next-line import/no-default-export +export default class extends Endpoint { + constructor( + @Inject(DI.abuseReportResolversRepository) + private abuseReportResolversRepository: AbuseReportResolversRepository, + ) { + super(meta, paramDef, async (ps, me) => { + const resolver = await this.abuseReportResolversRepository.findOneBy({ + id: ps.resolverId, + }); + + if (resolver === null) { + throw new ApiError(meta.errors.resolverNotFound); + } + + await this.abuseReportResolversRepository.delete(ps.resolverId); + }); + } +} diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/list.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/list.ts new file mode 100644 index 0000000000..7c381923e3 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/list.ts @@ -0,0 +1,77 @@ +import { Injectable, Inject } from '@nestjs/common'; +import { Brackets } from 'typeorm'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { DI } from '@/di-symbols.js'; +import { QueryService } from '@/core/QueryService.js'; +import type { AbuseReportResolversRepository } from '@/models/index.js'; + +export const meta = { + requireCredential: true, + + requireAdmin: true, + + res: { + type: 'array', + items: { + type: 'object', + properties: { + name: { + type: 'string', + nullable: false, optional: false, + }, + targetUserPattern: { + type: 'string', + nullable: true, optional: false, + }, + reporterPattern: { + type: 'string', + nullable: true, optional: false, + }, + reportContentPattern: { + type: 'string', + nullable: true, optional: false, + }, + expiresAt: { + type: 'string', + nullable: false, optional: false, + }, + forward: { + type: 'boolean', + nullable: false, optional: false, + }, + }, + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + limit: { type: 'number', minimum: 1, maximum: 100, default: 10 }, + sinceId: { type: 'string', format: 'misskey:id' }, + untilId: { type: 'string', format: 'misskey:id' }, + }, + required: [], +} as const; + +@Injectable() // eslint-disable-next-line import/no-default-export +export default class extends Endpoint { + constructor( + @Inject(DI.abuseReportResolversRepository) + private abuseReportResolversRepository: AbuseReportResolversRepository, + + private queryService: QueryService, + ) { + super(meta, paramDef, async (ps, me) => { + const query = this.queryService.makePaginationQuery(this.abuseReportResolversRepository.createQueryBuilder('abuseReportResolvers'), ps.sinceId, ps.untilId) + .andWhere(new Brackets(qb => { + qb.where('abuseReportResolvers.expirationDate > :date', { date: new Date() }); + qb.orWhere('abuseReportResolvers.expirationDate IS NULL'); + })) + .take(ps.limit); + + return await query.getMany(); + }); + } +} + diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts new file mode 100644 index 0000000000..53a447246d --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts @@ -0,0 +1,110 @@ +import { Injectable, Inject } from '@nestjs/common'; +import ms from 'ms'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { DI } from '@/di-symbols.js'; +import type { AbuseReportResolversRepository, AbuseReportResolver } from '@/models/index.js'; +import { ApiError } from '../../../error.js'; + +export const meta = { + requireCredential: true, + + requireAdmin: true, + + errors: { + resolverNotFound: { + message: 'Resolver not found.', + id: 'fd32710e-75e1-4d20-bbd2-f89029acb16e', + code: 'RESOLVER_NOT_FOUND', + }, + invalidRegularExpressionForTargetUser: { + message: 'Invalid regular expression for target user.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_TARGET_USER', + id: 'c008484a-0a14-4e74-86f4-b176dc49fcaa', + }, + invalidRegularExpressionForReporter: { + message: 'Invalid regular expression for reporter.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_REPORTER', + id: '399b4062-257f-44c8-87cc-4ffae2527fbc', + }, + invalidRegularExpressionForReportContent: { + message: 'Invalid regular expression for report content.', + code: 'INVALID_REGULAR_EXPRESSION_FOR_REPORT_CONTENT', + id: '88c124d8-f517-4c63-a464-0abc274168b', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + resolverId: { type: 'string', format: 'misskey:id' }, + name: { type: 'string' }, + targetUserPattern: { type: 'string', nullable: true }, + reporterPattern: { type: 'string', nullable: true }, + reportContentPattern: { type: 'string', nullable: true }, + expiresAt: { type: 'string', enum: ['1hour', '12hours', '1day', '1week', '1month', '3months', '6months', '1year', 'indefinitely'] }, + forward: { type: 'boolean' }, + }, + required: ['resolverId'], +} as const; + +@Injectable() // eslint-disable-next-line import/no-default-export +export default class extends Endpoint { + constructor( + @Inject(DI.abuseReportResolversRepository) + private abuseReportResolversRepository: AbuseReportResolversRepository, + ) { + super(meta, paramDef, async (ps, me) => { + const properties: Partial> = {}; + const resolver = await this.abuseReportResolversRepository.findOneBy({ + id: ps.resolverId, + }); + if (resolver === null) throw new ApiError(meta.errors.resolverNotFound); + if (ps.name) properties.name = ps.name; + if (ps.targetUserPattern) { + try { + new RegExp(ps.targetUserPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForTargetUser); + } + properties.targetUserPattern = ps.targetUserPattern; + } + if (ps.reporterPattern) { + try { + new RegExp(ps.reporterPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForReporter); + } + properties.reporterPattern = ps.reporterPattern; + } + if (ps.reportContentPattern) { + try { + new RegExp(ps.reportContentPattern); + } catch (e) { + throw new ApiError(meta.errors.invalidRegularExpressionForReportContent); + } + properties.reportContentPattern = ps.reportContentPattern; + } + if (ps.forward) properties.forward = ps.forward; + if (ps.expiresAt) { + let expirationDate: Date | null = new Date(); + (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : + ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : + ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : + ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : + ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1) / 12))); } : + ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3) / 12))); } : + ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6) % 12); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6) / 12))); } : + ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); + + properties.expiresAt = ps.expiresAt; + properties.expirationDate = expirationDate; + } + + await this.abuseReportResolversRepository.update(ps.resolverId, { + ...properties, + updatedAt: new Date(), + }); + }); + } +} diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index d19d4007d6..5dc59ec295 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -1,14 +1,11 @@ -import * as sanitizeHtml from 'sanitize-html'; import { Inject, Injectable } from '@nestjs/common'; import type { UsersRepository, AbuseUserReportsRepository } from '@/models/index.js'; import { IdService } from '@/core/IdService.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; -import { GlobalEventService } from '@/core/GlobalEventService.js'; -import { MetaService } from '@/core/MetaService.js'; -import { EmailService } from '@/core/EmailService.js'; import { DI } from '@/di-symbols.js'; import { GetterService } from '@/server/api/GetterService.js'; import { RoleService } from '@/core/RoleService.js'; +import { QueueService } from '@/core/QueueService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -59,11 +56,9 @@ export default class extends Endpoint { private abuseUserReportsRepository: AbuseUserReportsRepository, private idService: IdService, - private metaService: MetaService, - private emailService: EmailService, private getterService: GetterService, private roleService: RoleService, - private globalEventService: GlobalEventService, + private queueService: QueueService, ) { super(meta, paramDef, async (ps, me) => { // Lookup user @@ -90,26 +85,7 @@ export default class extends Endpoint { comment: ps.comment, }).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0])); - // Publish event to moderators - setImmediate(async () => { - const moderators = await this.roleService.getModerators(); - - for (const moderator of moderators) { - this.globalEventService.publishAdminStream(moderator.id, 'newAbuseUserReport', { - id: report.id, - targetUserId: report.targetUserId, - reporterId: report.reporterId, - comment: report.comment, - }); - } - - const meta = await this.metaService.fetch(); - if (meta.email) { - this.emailService.sendEmail(meta.email, 'New abuse report', - sanitizeHtml(ps.comment), - sanitizeHtml(ps.comment)); - } - }); + this.queueService.createReportAbuseJob(report); }); } } diff --git a/packages/frontend/src/components/MkAbuseReportResolver.vue b/packages/frontend/src/components/MkAbuseReportResolver.vue new file mode 100644 index 0000000000..3cf498f715 --- /dev/null +++ b/packages/frontend/src/components/MkAbuseReportResolver.vue @@ -0,0 +1,145 @@ + + + + diff --git a/packages/frontend/src/components/MkFolder.vue b/packages/frontend/src/components/MkFolder.vue index 70f0cc5cda..207661ba85 100644 --- a/packages/frontend/src/components/MkFolder.vue +++ b/packages/frontend/src/components/MkFolder.vue @@ -108,6 +108,10 @@ onMounted(() => { const myBg = computedStyle.getPropertyValue('--panel'); bgSame = parentBg === myBg; }); + +defineExpose({ + toggle, +}); diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index eddc5cf90c..48aa5f870a 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -423,6 +423,22 @@ export type Endpoints = { req: TODO; res: TODO; }; + 'admin/abuse-report-resolver/create': { + req: TODO; + res: TODO; + }; + 'admin/abuse-report-resolver/list': { + req: TODO; + res: TODO; + }; + 'admin/abuse-report-resolver/update': { + req: TODO; + res: TODO; + }; + 'admin/abuse-report-resolver/delete': { + req: TODO; + res: TODO; + }; 'admin/drive/clean-remote-files': { req: TODO; res: TODO; @@ -2723,7 +2739,7 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u // // src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts // src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts -// src/api.types.ts:596:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts +// src/api.types.ts:600:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index cc88c4b1a4..3a17e14d88 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -43,6 +43,10 @@ export type Endpoints = { 'admin/announcements/delete': { req: { id: Announcement['id'] }; res: null; }; 'admin/announcements/list': { req: TODO; res: TODO; }; 'admin/announcements/update': { req: TODO; res: TODO; }; + 'admin/abuse-report-resolver/create': { req: TODO; res: TODO; }; + 'admin/abuse-report-resolver/list': { req: TODO; res: TODO; }; + 'admin/abuse-report-resolver/update': { req: TODO; res: TODO; }; + 'admin/abuse-report-resolver/delete': { req: TODO; res: TODO; }; 'admin/drive/clean-remote-files': { req: TODO; res: TODO; }; 'admin/drive/cleanup': { req: TODO; res: TODO; }; 'admin/drive/files': { req: TODO; res: TODO; }; From 9b00b3556ec35fc34eb6f88d4da1a11f375b0ce5 Mon Sep 17 00:00:00 2001 From: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:01:10 +0900 Subject: [PATCH 002/525] =?UTF-8?q?fix:=20=E6=9D=A1=E4=BB=B6=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E6=99=82=E3=81=AB=E6=9C=89=E5=8A=B9=E6=9C=9F=E9=99=90?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=81=AE=E3=81=AB=E5=8B=9D=E6=89=8B=E3=81=AB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=95=E3=82=8C=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/MkAbuseReportResolver.vue | 12 +++++++++--- packages/frontend/src/pages/admin/abuses.vue | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/components/MkAbuseReportResolver.vue b/packages/frontend/src/components/MkAbuseReportResolver.vue index 3cf498f715..b970032d49 100644 --- a/packages/frontend/src/components/MkAbuseReportResolver.vue +++ b/packages/frontend/src/components/MkAbuseReportResolver.vue @@ -56,6 +56,7 @@ const props = defineProps<{ expiresAt: string; forward: boolean; expirationDate: string; + beforeExpiresAt?: string; } editable: boolean; data?: { @@ -77,9 +78,6 @@ const emit = defineEmits(['update:modelValue']); const value = computed({ get() { - if (props.modelValue && props.editable) { - emit('update:modelValue', props.data ?? props.modelValue); - } const data = props.data ?? props.modelValue ?? { name: '', targetUserPattern: '', @@ -93,6 +91,9 @@ const value = computed({ data[key] = ''; } } + if (props.modelValue && props.editable) { + emit('update:modelValue', data); + } return data as unknown as Exclude, undefined>; }, set(updateValue) { @@ -116,6 +117,11 @@ function renderExpirationDate(empty = false) { watch(() => value.value.expirationDate, () => renderExpirationDate(), { immediate: true }); watch(() => value.value.expiresAt, () => renderExpirationDate(true)); +watch(() => props.editable, () => { + if (props.editable) { + value.value.beforeExpiresAt = value.value.expiresAt; + } +}); diff --git a/packages/frontend/src/router.ts b/packages/frontend/src/router.ts index 52ca09be8b..0876e533d0 100644 --- a/packages/frontend/src/router.ts +++ b/packages/frontend/src/router.ts @@ -263,6 +263,9 @@ export const routes = [{ icon: 'icon', permission: 'permission', }, +}, { + path: '/oauth/authorize', + component: page(() => import('./pages/oauth.vue')), }, { path: '/tags/:tag', component: page(() => import('./pages/tag.vue')), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7b9b8d2be..42aeb357c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,6 +98,9 @@ importers: '@fastify/cors': specifier: 8.3.0 version: 8.3.0 + '@fastify/express': + specifier: 2.3.0 + version: 2.3.0 '@fastify/http-proxy': specifier: 9.2.1 version: 9.2.1(bufferutil@4.0.7)(utf-8-validate@6.0.3) @@ -149,6 +152,9 @@ importers: blurhash: specifier: 2.0.5 version: 2.0.5 + body-parser: + specifier: 1.20.2 + version: 1.20.2 bullmq: specifier: 4.4.0 version: 4.4.0 @@ -206,6 +212,9 @@ importers: hpagent: specifier: 1.2.0 version: 1.2.0 + http-link-header: + specifier: 1.1.0 + version: 1.1.0 ioredis: specifier: 5.3.2 version: 5.3.2 @@ -239,6 +248,9 @@ importers: mfm-js: specifier: 0.23.3 version: 0.23.3 + microformats-parser: + specifier: 1.4.1 + version: 1.4.1 mime-types: specifier: 2.1.35 version: 2.1.35 @@ -263,6 +275,12 @@ importers: oauth: specifier: 0.10.0 version: 0.10.0 + oauth2orize: + specifier: 1.11.1 + version: 1.11.1 + oauth2orize-pkce: + specifier: 0.1.2 + version: 0.1.2 os-utils: specifier: 0.0.14 version: 0.0.14 @@ -275,6 +293,9 @@ importers: pg: specifier: 8.11.1 version: 8.11.1 + pkce-challenge: + specifier: 4.0.1 + version: 4.0.1 probe-image-size: specifier: 7.2.3 version: 7.2.3 @@ -484,6 +505,9 @@ importers: '@types/bcryptjs': specifier: 2.4.2 version: 2.4.2 + '@types/body-parser': + specifier: 1.19.2 + version: 1.19.2 '@types/cbor': specifier: 6.0.0 version: 6.0.0 @@ -496,6 +520,9 @@ importers: '@types/fluent-ffmpeg': specifier: 2.1.21 version: 2.1.21 + '@types/http-link-header': + specifier: 1.0.3 + version: 1.0.3 '@types/jest': specifier: 29.5.3 version: 29.5.3 @@ -515,7 +542,7 @@ importers: specifier: 2.1.1 version: 2.1.1 '@types/ms': - specifier: ^0.7.31 + specifier: 0.7.31 version: 0.7.31 '@types/node': specifier: 20.4.2 @@ -529,6 +556,12 @@ importers: '@types/oauth': specifier: 0.9.1 version: 0.9.1 + '@types/oauth2orize': + specifier: 1.11.0 + version: 1.11.0 + '@types/oauth2orize-pkce': + specifier: 0.1.0 + version: 0.1.0 '@types/pg': specifier: 8.10.2 version: 8.10.2 @@ -559,6 +592,9 @@ importers: '@types/sharp': specifier: 0.32.0 version: 0.32.0 + '@types/simple-oauth2': + specifier: 5.0.4 + version: 5.0.4 '@types/sinonjs__fake-timers': specifier: 8.1.2 version: 8.1.2 @@ -604,6 +640,9 @@ importers: jest-mock: specifier: 29.6.1 version: 29.6.1 + simple-oauth2: + specifier: 5.0.0 + version: 5.0.0 packages/frontend: dependencies: @@ -4766,6 +4805,15 @@ packages: resolution: {integrity: sha512-KAfcLa+CnknwVi5fWogrLXgidLic+GXnLjijXdpl8pvkvbXU5BGa37iZO9FGvsh9ZL4y+oFi5cbHBm5UOG+dmQ==} dev: false + /@fastify/express@2.3.0: + resolution: {integrity: sha512-jvvjlPPCfJsSHfF6tQDyARJ3+c3xXiqcxVZu6bi3xMWCWB3fl07vrjFDeaqnwqKhLZ9+m6cog5dw7gIMKEsTnQ==} + dependencies: + express: 4.18.2 + fastify-plugin: 4.5.0 + transitivePeerDependencies: + - supports-color + dev: false + /@fastify/fast-json-stringify-compiler@4.3.0: resolution: {integrity: sha512-aZAXGYo6m22Fk1zZzEUKBvut/CIIQe/BapEORnxiD5Qr0kPHqqI69NtEMCme74h+at72sPhbkb4ZrLd1W3KRLA==} dependencies: @@ -4869,6 +4917,24 @@ packages: hashlru: 2.3.0 dev: false + /@hapi/boom@10.0.1: + resolution: {integrity: sha512-ERcCZaEjdH3OgSJlyjVk8pHIFeus91CjKP3v+MpgBNp5IvGzP2l/bRiD78nqYcKPaZdbKkK5vDBVPd2ohHBlsA==} + dependencies: + '@hapi/hoek': 11.0.2 + dev: true + + /@hapi/bourne@3.0.0: + resolution: {integrity: sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w==} + dev: true + + /@hapi/hoek@10.0.1: + resolution: {integrity: sha512-CvlW7jmOhWzuqOqiJQ3rQVLMcREh0eel4IBnxDx2FAcK8g7qoJRQK4L1CPBASoCY6y8e6zuCy3f2g+HWdkzcMw==} + dev: true + + /@hapi/hoek@11.0.2: + resolution: {integrity: sha512-aKmlCO57XFZ26wso4rJsW4oTUnrgTFw2jh3io7CAtO9w4UltBNwRXvXIVzzyfkaaLRo3nluP/19msA8vDUUuKw==} + dev: true + /@hapi/hoek@9.3.0: resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==} dev: true @@ -4879,6 +4945,14 @@ packages: '@hapi/hoek': 9.3.0 dev: true + /@hapi/wreck@18.0.1: + resolution: {integrity: sha512-OLHER70+rZxvDl75xq3xXOfd3e8XIvz8fWY0dqg92UvhZ29zo24vQgfqgHSYhB5ZiuFpSLeriOisAlxAo/1jWg==} + dependencies: + '@hapi/boom': 10.0.1 + '@hapi/bourne': 3.0.0 + '@hapi/hoek': 11.0.2 + dev: true + /@humanwhocodes/config-array@0.11.10: resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==} engines: {node: '>=10.10.0'} @@ -8079,6 +8153,12 @@ packages: /@types/http-cache-semantics@4.0.1: resolution: {integrity: sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==} + /@types/http-link-header@1.0.3: + resolution: {integrity: sha512-y8HkoD/vyid+5MrJ3aas0FvU3/BVBGcyG9kgxL0Zn4JwstA8CglFPnrR0RuzOjRCXwqzL5uxWC2IO7Ub0rMU2A==} + dependencies: + '@types/node': 20.4.2 + dev: true + /@types/istanbul-lib-coverage@2.0.4: resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} dev: true @@ -8222,6 +8302,19 @@ packages: resolution: {integrity: sha512-WKG4gTr8przEZBiJ5r3s8ZIAoMXNbOgQ+j/d5O4X3x6kZJRLNvyUJuUK/KoG3+8BaOHPhp2m7WC6JKKeovDSzQ==} dev: true + /@types/oauth2orize-pkce@0.1.0: + resolution: {integrity: sha512-k3FH+QtfjV/zAWFdJwzPOCISpYYXbGIwejtEbUWWGhUJ+gk/DyPesSKh3tblBkFBabN4RBRBRnYutWFwtVEZzw==} + dependencies: + '@types/oauth2orize': 1.11.0 + dev: true + + /@types/oauth2orize@1.11.0: + resolution: {integrity: sha512-jmnP/Ip36XBzs+nIn/I8wNBZkQcn/agmp8K9V81he+wOllLYMec8T8AqbRPJCFbnFwaL03bbR8gI3CknMCXohw==} + dependencies: + '@types/express': 4.17.17 + '@types/node': 20.4.2 + dev: true + /@types/oauth@0.9.1: resolution: {integrity: sha512-a1iY62/a3yhZ7qH7cNUsxoI3U/0Fe9+RnuFrpTKr+0WVOzbKlSLojShCKe20aOD1Sppv+i8Zlq0pLDuTJnwS4A==} dependencies: @@ -8352,6 +8445,10 @@ packages: sharp: 0.32.3 dev: true + /@types/simple-oauth2@5.0.4: + resolution: {integrity: sha512-4SvTfmAa1fGUa1d07j9vIiC4o92bGh0ihPXmtS05udMMmNwVIaU2nZ706cC4wI8cJxOlHD4P/d5tzqvWYd+KxA==} + dev: true + /@types/sinon@10.0.13: resolution: {integrity: sha512-UVjDqJblVNQYvVNUsj0PuYYw0ELRmgt1Nt5Vk0pT5f16ROGfcKJY8o1HVuMOJOpD727RrGB9EGvoaTQE5tgxZQ==} dependencies: @@ -9259,7 +9356,6 @@ packages: /array-flatten@1.1.1: resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==} - dev: true /array-includes@3.1.6: resolution: {integrity: sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==} @@ -9828,7 +9924,26 @@ packages: unpipe: 1.0.0 transitivePeerDependencies: - supports-color - dev: true + + /body-parser@1.20.2: + resolution: {integrity: sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==} + engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + dependencies: + bytes: 3.1.2 + content-type: 1.0.5 + debug: 2.6.9 + depd: 2.0.0 + destroy: 1.2.0 + http-errors: 2.0.0 + iconv-lite: 0.4.24 + on-finished: 2.4.1 + qs: 6.11.0 + raw-body: 2.5.2 + type-is: 1.6.18 + unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color + dev: false /boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -10006,7 +10121,6 @@ packages: /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - dev: true /c8@7.13.0: resolution: {integrity: sha512-/NL4hQTv1gBL6J6ei80zu3IiTrmePDKXKXOTLpHvcIWZTVYQlDhVWjjWvkhICylE8EwwnMVzDZugCvdx0/DIIA==} @@ -10742,7 +10856,6 @@ packages: /content-type@1.0.5: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} - dev: true /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} @@ -10753,7 +10866,6 @@ packages: /cookie-signature@1.0.6: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} - dev: true /cookie@0.4.2: resolution: {integrity: sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==} @@ -11306,7 +11418,6 @@ packages: /destroy@1.2.0: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - dev: true /detect-file@1.0.0: resolution: {integrity: sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==} @@ -11480,7 +11591,6 @@ packages: /ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - dev: true /ejs@3.1.8: resolution: {integrity: sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==} @@ -11511,7 +11621,6 @@ packages: /encodeurl@1.0.2: resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} engines: {node: '>= 0.8'} - dev: true /encoding@0.1.13: resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} @@ -12046,7 +12155,6 @@ packages: /etag@1.8.1: resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} engines: {node: '>= 0.6'} - dev: true /event-stream@3.3.4: resolution: {integrity: sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==} @@ -12227,7 +12335,6 @@ packages: vary: 1.1.2 transitivePeerDependencies: - supports-color - dev: true /ext-list@2.2.2: resolution: {integrity: sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==} @@ -12571,7 +12678,6 @@ packages: unpipe: 1.0.0 transitivePeerDependencies: - supports-color - dev: true /find-cache-dir@2.1.0: resolution: {integrity: sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==} @@ -12814,7 +12920,6 @@ packages: /fresh@0.5.2: resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} engines: {node: '>= 0.6'} - dev: true /from@0.1.7: resolution: {integrity: sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==} @@ -13625,6 +13730,11 @@ packages: statuses: 2.0.1 toidentifier: 1.0.1 + /http-link-header@1.1.0: + resolution: {integrity: sha512-pj6N1yxOz/ANO8HHsWGg/OoIL1kmRYvQnXQ7PIRpgp+15AnEsRH8fmIJE6D1OdWG2Bov+BJHVla1fFXxg1JbbA==} + engines: {node: '>=6.0.0'} + dev: false + /http-proxy-agent@5.0.0: resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==} engines: {node: '>= 6'} @@ -15786,7 +15896,6 @@ packages: /media-typer@0.3.0: resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} engines: {node: '>= 0.6'} - dev: true /meilisearch@0.33.0: resolution: {integrity: sha512-bYPb9WyITnJfzf92e7QFK8Rc50DmshFWxypXCs3ILlpNh8pT15A7KSu9Xgnnk/K3G/4vb3wkxxtFS4sxNkWB8w==} @@ -15822,7 +15931,6 @@ packages: /merge-descriptors@1.0.1: resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==} - dev: true /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -15834,7 +15942,6 @@ packages: /methods@1.1.2: resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} engines: {node: '>= 0.6'} - dev: true /mfm-js@0.23.3: resolution: {integrity: sha512-o8scYmbey6rMUmWAlT3k3ntt6khaCLdxlmHhAWV5wTTMj2OK1atQvZfRUq0SIVm1Jig08qlZg/ps71xUqrScNA==} @@ -15842,6 +15949,13 @@ packages: twemoji-parser: 14.0.0 dev: false + /microformats-parser@1.4.1: + resolution: {integrity: sha512-BSg9Y/Aik8hvvme/fkxnXMRvTKuVwOeTapeZdaPQ+92DEubyM31iMtwbgFZ1383om643UvfYY5G23E9s1FY2KQ==} + engines: {node: '>=10'} + dependencies: + parse5: 6.0.1 + dev: false + /micromatch@3.1.10: resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==} engines: {node: '>=0.10.0'} @@ -15884,7 +15998,6 @@ packages: resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} engines: {node: '>=4'} hasBin: true - dev: true /mime@2.6.0: resolution: {integrity: sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==} @@ -16590,6 +16703,21 @@ packages: resolution: {integrity: sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==} dev: false + /oauth2orize-pkce@0.1.2: + resolution: {integrity: sha512-grto2UYhXHi9GLE3IBgBBbV87xci55+bCyjpVuxKyzol6I5Rg0K1MiTuXE+JZk54R86SG2wqXODMiZYHraPpxw==} + dev: false + + /oauth2orize@1.11.1: + resolution: {integrity: sha512-9dSx/Gwm0J2Rvj4RH9+h7iXVnRXZ6biwWRgb2dCeQhCosODS0nYdM9I/G7BUGsjbgn0pHjGcn1zcCRtzj2SlRA==} + engines: {node: '>= 0.4.0'} + dependencies: + debug: 2.6.9 + uid2: 0.0.4 + utils-merge: 1.0.1 + transitivePeerDependencies: + - supports-color + dev: false + /oauth@0.10.0: resolution: {integrity: sha512-1orQ9MT1vHFGQxhuy7E/0gECD3fd2fCC+PIX+/jgmU/gI3EpRocXtmtvxCO5x3WZ443FLTLFWNDjl5MPJf9u+Q==} dev: false @@ -16609,7 +16737,6 @@ packages: /object-inspect@1.12.2: resolution: {integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==} - dev: true /object-is@1.1.5: resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} @@ -16706,7 +16833,6 @@ packages: engines: {node: '>= 0.8'} dependencies: ee-first: 1.1.1 - dev: true /on-headers@1.0.2: resolution: {integrity: sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==} @@ -17015,7 +17141,6 @@ packages: /parseurl@1.3.3: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} - dev: true /pascalcase@0.1.1: resolution: {integrity: sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==} @@ -17084,7 +17209,6 @@ packages: /path-to-regexp@0.1.7: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} - dev: true /path-to-regexp@1.8.0: resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==} @@ -17292,6 +17416,11 @@ packages: engines: {node: '>= 6'} dev: true + /pkce-challenge@4.0.1: + resolution: {integrity: sha512-WGmtS1stcStsvRwNXix3iR1ujFcDaJR+sEODRa2ZFruT0lM4lhPAFTL5SUpqD5vTJdRlgtuMQhcp1kIEJx4LUw==} + engines: {node: '>=16.20.0'} + dev: false + /pkg-dir@3.0.0: resolution: {integrity: sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==} engines: {node: '>=6'} @@ -18017,7 +18146,6 @@ packages: engines: {node: '>=0.6'} dependencies: side-channel: 1.0.4 - dev: true /qs@6.11.1: resolution: {integrity: sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==} @@ -18085,7 +18213,6 @@ packages: /range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} engines: {node: '>= 0.6'} - dev: true /ratelimiter@3.4.1: resolution: {integrity: sha512-5FJbRW/Jkkdk29ksedAfWFkQkhbUrMx3QJGwMKAypeIiQf4yrLW+gtPKZiaWt4zPrtw1uGufOjGO7UGM6VllsQ==} @@ -18099,7 +18226,16 @@ packages: http-errors: 2.0.0 iconv-lite: 0.4.24 unpipe: 1.0.0 - dev: true + + /raw-body@2.5.2: + resolution: {integrity: sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==} + engines: {node: '>= 0.8'} + dependencies: + bytes: 3.1.2 + http-errors: 2.0.0 + iconv-lite: 0.4.24 + unpipe: 1.0.0 + dev: false /rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} @@ -18942,7 +19078,6 @@ packages: statuses: 2.0.1 transitivePeerDependencies: - supports-color - dev: true /serve-favicon@2.5.0: resolution: {integrity: sha512-FMW2RvqNr03x+C0WxTyu6sOv21oOjkq5j8tjquWccwa6ScNyGFOGJVpuS1NmTVGBAHS07xnSKotgf2ehQmf9iA==} @@ -18965,7 +19100,6 @@ packages: send: 0.18.0 transitivePeerDependencies: - supports-color - dev: true /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} @@ -19072,7 +19206,6 @@ packages: call-bind: 1.0.2 get-intrinsic: 1.2.0 object-inspect: 1.12.2 - dev: true /siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} @@ -19100,6 +19233,17 @@ packages: once: 1.4.0 simple-concat: 1.0.1 + /simple-oauth2@5.0.0: + resolution: {integrity: sha512-8291lo/z5ZdpmiOFzOs1kF3cxn22bMj5FFH+DNUppLJrpoIlM1QnFiE7KpshHu3J3i21TVcx4yW+gXYjdCKDLQ==} + dependencies: + '@hapi/hoek': 10.0.1 + '@hapi/wreck': 18.0.1 + debug: 4.3.4(supports-color@8.1.1) + joi: 17.7.0 + transitivePeerDependencies: + - supports-color + dev: true + /simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} dependencies: @@ -20375,7 +20519,6 @@ packages: dependencies: media-typer: 0.3.0 mime-types: 2.1.35 - dev: true /type@1.2.0: resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==} @@ -20490,6 +20633,10 @@ packages: dev: true optional: true + /uid2@0.0.4: + resolution: {integrity: sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA==} + dev: false + /uid@2.0.2: resolution: {integrity: sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==} engines: {node: '>=8'} @@ -20660,7 +20807,6 @@ packages: /unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - dev: true /unplugin@0.10.2: resolution: {integrity: sha512-6rk7GUa4ICYjae5PrAllvcDeuT8pA9+j5J5EkxbMFaV+SalHhxZ7X2dohMzu6C3XzsMT+6jwR/+pwPNR3uK9MA==} @@ -20764,7 +20910,6 @@ packages: /utils-merge@1.0.1: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} - dev: true /uuid@3.4.0: resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} From 8b74d1530ed57d5f1a222de3a62ca8787b050149 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 27 Jul 2023 19:34:51 +0900 Subject: [PATCH 031/525] Update ROADMAP.md --- ROADMAP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROADMAP.md b/ROADMAP.md index 420f728758..3077c41e73 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -22,7 +22,7 @@ This is the phase we are at now. We need to make a high-maintenance environment Once Phase 1 is complete and an environment conducive to the development of a stable system is in place, the implementation of new functions can begin gradually. - Improve features for moderation -- OAuth2 support https://github.com/misskey-dev/misskey/issues/8262 +- ~~OAuth2 support https://github.com/misskey-dev/misskey/issues/8262~~ → Done ✔️ - GraphQL support? ## (3) Improve scalability From 63359f5fc47f8604e459e7c53579f9e3f75c9ddc Mon Sep 17 00:00:00 2001 From: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:11:25 +0900 Subject: [PATCH 032/525] =?UTF-8?q?Fix:=20=E7=84=A1=E9=99=90=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=97=E3=82=92=E6=8A=91=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/queue/processors/ReportAbuseProcessorService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts b/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts index 70e0a095c2..d1ff3a5a49 100644 --- a/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts +++ b/packages/backend/src/queue/processors/ReportAbuseProcessorService.ts @@ -76,16 +76,16 @@ export class ReportAbuseProcessorService { const isReportContentPatternMatched = resolver.reportContentPattern ? new RE2(resolver.reportContentPattern).test(job.data.comment) : true; if (isTargetUserPatternMatched && isReporterPatternMatched && isReportContentPatternMatched) { - if (resolver.forward && job.data.targetUserHost !== null) { + if (resolver.forward && job.data.targetUserHost !== null && job.data.reporterHost === null) { this.queueService.deliver(actor, this.apRendererService.addContext(this.apRendererService.renderFlag(actor, targetUser.uri!, job.data.comment)), targetUser.inbox, false); } await this.abuseUserReportsRepository.update(job.data.id, { resolved: true, assigneeId: actor.id, - forwarded: resolver.forward && job.data.targetUserHost !== null, + forwarded: resolver.forward && job.data.targetUserHost !== null && job.data.reporterHost === null, }); - + return; } } From ab3cd7b8372f4e858e630de228f3211e13a39c06 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 28 Jul 2023 14:02:58 +0900 Subject: [PATCH 033/525] chore: add missing license identifier --- packages/backend/src/server/oauth/OAuth2ProviderService.ts | 5 +++++ packages/backend/test/e2e/oauth.ts | 5 +++++ packages/frontend/src/pages/oauth.vue | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index 93cbaa4035..61c89a4258 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + import dns from 'node:dns/promises'; import { fileURLToPath } from 'node:url'; import { Inject, Injectable } from '@nestjs/common'; diff --git a/packages/backend/test/e2e/oauth.ts b/packages/backend/test/e2e/oauth.ts index 9048c2f7e2..a029a0d4be 100644 --- a/packages/backend/test/e2e/oauth.ts +++ b/packages/backend/test/e2e/oauth.ts @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + /** * Basic OAuth tests to make sure the library is correctly integrated to Misskey * and not regressed by version updates or potential migration to another library. diff --git a/packages/frontend/src/pages/oauth.vue b/packages/frontend/src/pages/oauth.vue index 6a72057f46..0dbaed1081 100644 --- a/packages/frontend/src/pages/oauth.vue +++ b/packages/frontend/src/pages/oauth.vue @@ -1,3 +1,8 @@ + +