2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-14 00:59:27 +09:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
2024-09-22 12:53:13 +09:00
|
|
|
import type { MiMeta, UsersRepository } from '@/models/_.js';
|
2023-09-20 11:33:36 +09:00
|
|
|
import type { MiLocalUser } from '@/models/User.js';
|
2022-09-18 03:27:08 +09:00
|
|
|
import { DI } from '@/di-symbols.js';
|
2022-12-04 15:03:09 +09:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2022-09-18 03:27:08 +09:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ProxyAccountService {
|
|
|
|
constructor(
|
2024-09-22 12:53:13 +09:00
|
|
|
@Inject(DI.meta)
|
|
|
|
private meta: MiMeta,
|
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
@Inject(DI.usersRepository)
|
|
|
|
private usersRepository: UsersRepository,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2022-12-04 15:03:09 +09:00
|
|
|
@bindThis
|
2023-08-16 17:51:28 +09:00
|
|
|
public async fetch(): Promise<MiLocalUser | null> {
|
2024-09-22 12:53:13 +09:00
|
|
|
if (this.meta.proxyAccountId == null) return null;
|
|
|
|
return await this.usersRepository.findOneByOrFail({ id: this.meta.proxyAccountId }) as MiLocalUser;
|
2022-09-18 03:27:08 +09:00
|
|
|
}
|
|
|
|
}
|