getUserUriをUserEntityServiceに

This commit is contained in:
tamaina 2023-04-22 13:37:09 +00:00
parent 70d34aa05c
commit 5115ff1466
16 changed files with 107 additions and 84 deletions

View file

@ -4,7 +4,7 @@ import chalk from 'chalk';
import { IsNull } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { UsersRepository } from '@/models/index.js';
import type { RemoteUser, User } from '@/models/entities/User.js';
import type { LocalUser, RemoteUser } from '@/models/entities/User.js';
import type { Config } from '@/config.js';
import type Logger from '@/logger.js';
import { UtilityService } from '@/core/UtilityService.js';
@ -33,7 +33,7 @@ export class RemoteUserResolveService {
}
@bindThis
public async resolveUser(username: string, host: string | null): Promise<User> {
public async resolveUser(username: string, host: string | null): Promise<LocalUser | RemoteUser> {
const usernameLower = username.toLowerCase();
if (host == null) {
@ -44,7 +44,7 @@ export class RemoteUserResolveService {
} else {
return u;
}
});
}) as LocalUser;
}
host = this.utilityService.toPuny(host);
@ -57,7 +57,7 @@ export class RemoteUserResolveService {
} else {
return u;
}
});
}) as LocalUser;
}
const user = await this.usersRepository.findOneBy({ usernameLower, host }) as RemoteUser | null;
@ -109,7 +109,7 @@ export class RemoteUserResolveService {
if (u == null) {
throw new Error('user not found');
} else {
return u;
return u as LocalUser | RemoteUser;
}
});
}