mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 06:00:21 +01:00
移行を行ったアカウントからのフォローリクエストの自動許可を調整
This commit is contained in:
parent
6b82d3a1d4
commit
51a867473b
2 changed files with 24 additions and 8 deletions
|
@ -143,16 +143,32 @@ export class UserFollowingService implements OnModuleInit {
|
|||
// Automatically accept if the follower is an account who has moved and the locked followee had accepted the old account.
|
||||
if (followee.isLocked && !autoAccept) {
|
||||
let movedFollower = follower;
|
||||
|
||||
if (this.userEntityService.isRemoteUser(movedFollower)) {
|
||||
await this.apPersonService.updatePerson(movedFollower.uri);
|
||||
movedFollower = await this.apPersonService.resolvePerson(movedFollower.uri);
|
||||
if ((new Date()).getTime() - (movedFollower.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||
await this.apPersonService.updatePerson(movedFollower.uri);
|
||||
}
|
||||
movedFollower = await this.apPersonService.fetchPerson(movedFollower.uri) ?? follower;
|
||||
}
|
||||
|
||||
if (movedFollower.alsoKnownAs) {
|
||||
for (const oldUri of movedFollower.alsoKnownAs) {
|
||||
try {
|
||||
await this.apPersonService.updatePerson(oldUri);
|
||||
const oldAccount = await this.apPersonService.resolvePerson(oldUri);
|
||||
const newUri = this.userEntityService.isRemoteUser(movedFollower) ? movedFollower.uri : `${this.config.url}/users/${movedFollower.id}`;
|
||||
let oldAccount = await this.apPersonService.fetchPerson(oldUri);
|
||||
if (!oldAccount) continue; // oldAccountを探してもこのサーバーに存在しない場合はフォロー関係もないということなのでスルー
|
||||
|
||||
let newUri: string;
|
||||
|
||||
if (this.userEntityService.isRemoteUser(movedFollower)) {
|
||||
if ((new Date()).getTime() - (oldAccount.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||
await this.apPersonService.updatePerson(oldUri);
|
||||
}
|
||||
|
||||
oldAccount = await this.apPersonService.fetchPerson(oldUri) ?? oldAccount;
|
||||
newUri = movedFollower.uri;
|
||||
} else {
|
||||
newUri = `${this.config.url}/users/${movedFollower.id}`;
|
||||
}
|
||||
|
||||
autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({
|
||||
where: {
|
||||
|
|
|
@ -205,12 +205,12 @@ export class ApPersonService implements OnModuleInit {
|
|||
}
|
||||
|
||||
/**
|
||||
* Personをフェッチします。
|
||||
* uriからUser(Person)をフェッチします。
|
||||
*
|
||||
* Misskeyに対象のPersonが登録されていればそれを返します。
|
||||
* Misskeyに対象のPersonが登録されていればそれを返し、登録がなければnullを返します。
|
||||
*/
|
||||
@bindThis
|
||||
public async fetchPerson(uri: string, resolver?: Resolver): Promise<User | null> {
|
||||
public async fetchPerson(uri: string): Promise<User | null> {
|
||||
if (typeof uri !== 'string') throw new Error('uri is not string');
|
||||
|
||||
const cached = this.cacheService.uriPersonCache.get(uri);
|
||||
|
|
Loading…
Reference in a new issue