forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance: アカウント移行機能を使用したユーザーに対してのモデレーションの強化 (#719)
* fix * fix * fix * Feat: アカウント移行機能のモデレーションを行いやすくした * コミット忘れ * 文章を組み立てるのやめた * Fix test * Fix test * updateModerationNote から mergeModerationNote に * updateAccountMoveLogs から insertAccountMoveLog に --------- Co-authored-by: nenohi <[email protected]> Co-authored-by: nenohi <[email protected]>
- Loading branch information
1 parent
2fe5bb0
commit 6c732d1
Showing
29 changed files
with
593 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/backend/migration/1724749627479-useraccountmovelogs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export class Useraccountmovelogs1724749627479 { | ||
name = 'Useraccountmovelogs1724749627479' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`CREATE TABLE "user_account_move_log" ("id" character varying(32) NOT NULL, "movedToId" character varying(32) NOT NULL, "movedFromId" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_8ffd4ae965a5e3a0fbf4b084212" PRIMARY KEY ("id")); COMMENT ON COLUMN "user_account_move_log"."createdAt" IS 'The created date of the UserIp.'`); | ||
await queryRunner.query(`CREATE INDEX "IDX_d5ee7d4d1b5e7a69d8855ab069" ON "user_account_move_log" ("movedToId") `); | ||
await queryRunner.query(`CREATE INDEX "IDX_82930731d6390e7bb429a1938f" ON "user_account_move_log" ("movedFromId") `); | ||
await queryRunner.query(`ALTER TABLE "user_account_move_log" ADD CONSTRAINT "FK_d5ee7d4d1b5e7a69d8855ab0696" FOREIGN KEY ("movedToId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
await queryRunner.query(`ALTER TABLE "user_account_move_log" ADD CONSTRAINT "FK_82930731d6390e7bb429a1938f8" FOREIGN KEY ("movedFromId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "user_account_move_log" DROP CONSTRAINT "FK_82930731d6390e7bb429a1938f8"`); | ||
await queryRunner.query(`ALTER TABLE "user_account_move_log" DROP CONSTRAINT "FK_d5ee7d4d1b5e7a69d8855ab0696"`); | ||
await queryRunner.query(`DROP INDEX "public"."IDX_82930731d6390e7bb429a1938f"`); | ||
await queryRunner.query(`DROP INDEX "public"."IDX_d5ee7d4d1b5e7a69d8855ab069"`); | ||
await queryRunner.query(`DROP TABLE "user_account_move_log"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/backend/src/core/entities/UserAccountMoveLogEntityService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { DI } from '@/di-symbols.js'; | ||
import type { MiUserAccountMoveLog, UserAccountMoveLogRepository } from '@/models/_.js'; | ||
import { awaitAll } from '@/misc/prelude/await-all.js'; | ||
import type { MiUser } from '@/models/User.js'; | ||
import { bindThis } from '@/decorators.js'; | ||
import { Packed } from '@/misc/json-schema.js'; | ||
import { IdService } from '@/core/IdService.js'; | ||
import { UserEntityService } from './UserEntityService.js'; | ||
|
||
@Injectable() | ||
export class UserAccountMoveLogEntityService { | ||
constructor( | ||
@Inject(DI.userAccountMoveLogRepository) | ||
private userAccountMoveLogRepository: UserAccountMoveLogRepository, | ||
|
||
private userEntityService: UserEntityService, | ||
private idService: IdService, | ||
) { | ||
} | ||
|
||
@bindThis | ||
public async pack( | ||
src: MiUserAccountMoveLog['id'] | MiUserAccountMoveLog, | ||
me: { id: MiUser['id'] } | null | undefined, | ||
) : Promise<Packed<'UserAccountMoveLog'>> { | ||
const log = typeof src === 'object' ? src : await this.userAccountMoveLogRepository.findOneByOrFail({ id: src }); | ||
|
||
return await awaitAll({ | ||
id: log.id, | ||
createdAt: this.idService.parse(log.id).date.toISOString(), | ||
movedFromId: log.movedFromId, | ||
movedFrom: this.userEntityService.pack(log.movedFrom ?? log.movedFromId, me, { | ||
schema: 'UserDetailed', | ||
}), | ||
movedToId: log.movedToId, | ||
movedTo: this.userEntityService.pack(log.movedTo ?? log.movedToId, me, { | ||
schema: 'UserDetailed', | ||
}), | ||
}); | ||
} | ||
|
||
@bindThis | ||
public async packMany( | ||
reports: (MiUserAccountMoveLog['id'] | MiUserAccountMoveLog)[], | ||
me: { id: MiUser['id'] } | null | undefined, | ||
) : Promise<Packed<'UserAccountMoveLog'>[]> { | ||
return (await Promise.allSettled(reports.map(x => this.pack(x, me)))) | ||
.filter(result => result.status === 'fulfilled') | ||
.map(result => (result as PromiseFulfilledResult<Packed<'UserAccountMoveLog'>>).value); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Entity, Index, Column, ManyToOne, JoinColumn, PrimaryColumn } from 'typeorm'; | ||
import { id } from './util/id.js'; | ||
import { MiUser } from './User.js'; | ||
|
||
@Entity('user_account_move_log') | ||
export class MiUserAccountMoveLog { | ||
@PrimaryColumn(id()) | ||
public id: string; | ||
|
||
@Index() | ||
@Column(id()) | ||
public movedToId: MiUser['id']; | ||
|
||
@ManyToOne(type => MiUser, { | ||
onDelete: 'CASCADE', | ||
}) | ||
@JoinColumn() | ||
public movedTo: MiUser | null; | ||
|
||
@Index() | ||
@Column(id()) | ||
public movedFromId: MiUser['id']; | ||
|
||
@ManyToOne(type => MiUser, { | ||
onDelete: 'CASCADE', | ||
}) | ||
@JoinColumn() | ||
public movedFrom: MiUser | null; | ||
|
||
@Column('timestamp with time zone', { | ||
comment: 'The created date of the UserIp.', | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public createdAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.