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