ignore instance.actor
when checking if there are local users (#13146)
* ignore `instance.actor` when checking if there are local users We've seen this happen a few times: * there was some AP software at $some_domain * it gets replaced by Misskey * before the first user can be created, an AP activity comes in * Misskey resolves the activity * to do this, it creates the `instance.actor` to sign its request * now there *is* a local user, so the `meta` endpoint returns `requireSetup:false` * the admin is very confused This commit factors out the check, and doesn't count the `instance.actor` as a real user. * autogen bits
This commit is contained in:
parent
2c4ba4723f
commit
bafef1f8b4
9 changed files with 25 additions and 18 deletions
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { IsNull } from 'typeorm';
|
||||
import { IsNull, Not } from 'typeorm';
|
||||
import type { MiLocalUser } from '@/models/User.js';
|
||||
import type { UsersRepository } from '@/models/_.js';
|
||||
import { MemorySingleCache } from '@/misc/cache.js';
|
||||
|
@ -27,6 +27,14 @@ export class InstanceActorService {
|
|||
this.cache = new MemorySingleCache<MiLocalUser>(Infinity);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async realLocalUsersPresent(): Promise<boolean> {
|
||||
return await this.usersRepository.existsBy({
|
||||
host: IsNull(),
|
||||
username: Not(ACTOR_USERNAME),
|
||||
});
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async getInstanceActor(): Promise<MiLocalUser> {
|
||||
const cached = this.cache.get();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue