refactor: prefix Mi for all entities (#11719)
* wip
* wip
* wip
* wip
* Update RepositoryModule.ts
* wip
* wip
* wip
* Revert "wip"
This reverts commit c1c13b37d2
.
This commit is contained in:
@@ -9,11 +9,11 @@ import bcrypt from 'bcryptjs';
|
||||
import { DataSource, IsNull } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { UsedUsernamesRepository, UsersRepository } from '@/models/index.js';
|
||||
import { User } from '@/models/entities/User.js';
|
||||
import { UserProfile } from '@/models/entities/UserProfile.js';
|
||||
import { MiUser } from '@/models/entities/User.js';
|
||||
import { MiUserProfile } from '@/models/entities/UserProfile.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { UserKeypair } from '@/models/entities/UserKeypair.js';
|
||||
import { UsedUsername } from '@/models/entities/UsedUsername.js';
|
||||
import { MiUserKeypair } from '@/models/entities/UserKeypair.js';
|
||||
import { MiUsedUsername } from '@/models/entities/UsedUsername.js';
|
||||
import generateUserToken from '@/misc/generate-native-user-token.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
@@ -43,9 +43,9 @@ export class SignupService {
|
||||
|
||||
@bindThis
|
||||
public async signup(opts: {
|
||||
username: User['username'];
|
||||
username: MiUser['username'];
|
||||
password?: string | null;
|
||||
passwordHash?: UserProfile['password'] | null;
|
||||
passwordHash?: MiUserProfile['password'] | null;
|
||||
host?: string | null;
|
||||
ignorePreservedUsernames?: boolean;
|
||||
}) {
|
||||
@@ -108,18 +108,18 @@ export class SignupService {
|
||||
err ? rej(err) : res([publicKey, privateKey]),
|
||||
));
|
||||
|
||||
let account!: User;
|
||||
let account!: MiUser;
|
||||
|
||||
// Start transaction
|
||||
await this.db.transaction(async transactionalEntityManager => {
|
||||
const exist = await transactionalEntityManager.findOneBy(User, {
|
||||
const exist = await transactionalEntityManager.findOneBy(MiUser, {
|
||||
usernameLower: username.toLowerCase(),
|
||||
host: IsNull(),
|
||||
});
|
||||
|
||||
if (exist) throw new Error(' the username is already used');
|
||||
|
||||
account = await transactionalEntityManager.save(new User({
|
||||
account = await transactionalEntityManager.save(new MiUser({
|
||||
id: this.idService.genId(),
|
||||
createdAt: new Date(),
|
||||
username: username,
|
||||
@@ -129,19 +129,19 @@ export class SignupService {
|
||||
isRoot: isTheFirstUser,
|
||||
}));
|
||||
|
||||
await transactionalEntityManager.save(new UserKeypair({
|
||||
await transactionalEntityManager.save(new MiUserKeypair({
|
||||
publicKey: keyPair[0],
|
||||
privateKey: keyPair[1],
|
||||
userId: account.id,
|
||||
}));
|
||||
|
||||
await transactionalEntityManager.save(new UserProfile({
|
||||
await transactionalEntityManager.save(new MiUserProfile({
|
||||
userId: account.id,
|
||||
autoAcceptFollowed: true,
|
||||
password: hash,
|
||||
}));
|
||||
|
||||
await transactionalEntityManager.save(new UsedUsername({
|
||||
await transactionalEntityManager.save(new MiUsedUsername({
|
||||
createdAt: new Date(),
|
||||
username: username.toLowerCase(),
|
||||
}));
|
||||
|
Reference in New Issue
Block a user