mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 08:10:24 +01:00
automatically accept if a locked account had accepted an old account
This commit is contained in:
parent
75c2c105fb
commit
71a2fbd232
2 changed files with 21 additions and 1 deletions
|
@ -22,6 +22,7 @@ import { MetaService } from '@/core/MetaService.js';
|
|||
import { CacheService } from '@/core/CacheService.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import Logger from '../logger.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
|
||||
const logger = new Logger('following/create');
|
||||
|
||||
|
@ -73,6 +74,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
private federatedInstanceService: FederatedInstanceService,
|
||||
private webhookService: WebhookService,
|
||||
private apRendererService: ApRendererService,
|
||||
private apPersonService: ApPersonService,
|
||||
private perUserFollowingChart: PerUserFollowingChart,
|
||||
private instanceChart: InstanceChart,
|
||||
) {
|
||||
|
@ -137,6 +139,24 @@ export class UserFollowingService implements OnModuleInit {
|
|||
if (followed) autoAccept = true;
|
||||
}
|
||||
|
||||
// Automatically accept if the follower is an account who has moved and the locked followee had accepted the old account.
|
||||
if (followee.isLocked && !autoAccept && follower.alsoKnownAs) {
|
||||
for (const oldUri of follower.alsoKnownAs) {
|
||||
try {
|
||||
await this.apPersonService.updatePerson(oldUri);
|
||||
const oldAccount = await this.apPersonService.resolvePerson(oldUri);
|
||||
autoAccept = await this.followingsRepository.exist({
|
||||
where: {
|
||||
followeeId: followee.id,
|
||||
followerId: oldAccount.id,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
/* skip if any error happens */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!autoAccept) {
|
||||
await this.createFollowRequest(follower, followee, requestId);
|
||||
return;
|
||||
|
|
|
@ -217,7 +217,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
if (cached) return cached;
|
||||
|
||||
// URIがこのサーバーを指しているならデータベースからフェッチ
|
||||
if (uri.startsWith(this.config.url + '/')) {
|
||||
if (uri.startsWith(`${this.config.url}/`)) {
|
||||
const id = uri.split('/').pop();
|
||||
const u = await this.usersRepository.findOneBy({ id });
|
||||
if (u) this.cacheService.uriPersonCache.set(uri, u);
|
||||
|
|
Loading…
Reference in a new issue