mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-24 14:23:08 +02:00
Fix: リモートユーザーの修復処理が自動的に実行されない など for v11 (#4764)
* Fix #4761 * Fix: updatePersonができない
This commit is contained in:
parent
ae43aa1bc0
commit
a78475844a
3 changed files with 17 additions and 23 deletions
|
@ -271,11 +271,6 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// 繋がらないインスタンスに何回も試行するのを防ぐ, 後続の同様処理の連続試行を防ぐ ため 試行前にも更新する
|
|
||||||
await Users.update(exist.id, {
|
|
||||||
lastFetchedAt: new Date(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (resolver == null) resolver = new Resolver();
|
if (resolver == null) resolver = new Resolver();
|
||||||
|
|
||||||
const object = hint || await resolver.resolve(uri) as any;
|
const object = hint || await resolver.resolve(uri) as any;
|
||||||
|
@ -349,13 +344,13 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
|
||||||
url: person.url,
|
url: person.url,
|
||||||
fields,
|
fields,
|
||||||
description: person.summary ? fromHtml(person.summary) : null,
|
description: person.summary ? fromHtml(person.summary) : null,
|
||||||
twitterUserId: services.twitter.userId,
|
twitterUserId: services.twitter ? services.twitter.userId : null,
|
||||||
twitterScreenName: services.twitter.screenName,
|
twitterScreenName: services.twitter ? services.twitter.screenName : null,
|
||||||
githubId: services.github.id,
|
githubId: services.github ? services.github.id : null,
|
||||||
githubLogin: services.github.login,
|
githubLogin: services.github ? services.github.login : null,
|
||||||
discordId: services.discord.id,
|
discordId: services.discord ? services.discord.id : null,
|
||||||
discordUsername: services.discord.username,
|
discordUsername: services.discord ? services.discord.username : null,
|
||||||
discordDiscriminator: services.discord.discriminator,
|
discordDiscriminator: services.discord ? services.discord.discriminator : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ハッシュタグ更新
|
// ハッシュタグ更新
|
||||||
|
|
|
@ -37,7 +37,7 @@ export async function resolveUser(username: string, host: string | null, option?
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await Users.findOne({ usernameLower, host }, option);
|
const user = await Users.findOne({ usernameLower, host }, option) as IRemoteUser;
|
||||||
|
|
||||||
const acctLower = `${usernameLower}@${host}`;
|
const acctLower = `${usernameLower}@${host}`;
|
||||||
|
|
||||||
|
@ -48,14 +48,20 @@ export async function resolveUser(username: string, host: string | null, option?
|
||||||
return await createPerson(self.href);
|
return await createPerson(self.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resync) {
|
// resyncオプション OR ユーザー情報が古い場合は、WebFilgerからやりなおして返す
|
||||||
|
if (resync || user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) {
|
||||||
|
// 繋がらないインスタンスに何回も試行するのを防ぐ, 後続の同様処理の連続試行を防ぐ ため 試行前にも更新する
|
||||||
|
await Users.update(user.id, {
|
||||||
|
lastFetchedAt: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
logger.info(`try resync: ${acctLower}`);
|
logger.info(`try resync: ${acctLower}`);
|
||||||
const self = await resolveSelf(acctLower);
|
const self = await resolveSelf(acctLower);
|
||||||
|
|
||||||
if ((user as IRemoteUser).uri !== self.href) {
|
if (user.uri !== self.href) {
|
||||||
// if uri mismatch, Fix (user@host <=> AP's Person id(IRemoteUser.uri)) mapping.
|
// if uri mismatch, Fix (user@host <=> AP's Person id(IRemoteUser.uri)) mapping.
|
||||||
logger.info(`uri missmatch: ${acctLower}`);
|
logger.info(`uri missmatch: ${acctLower}`);
|
||||||
logger.info(`recovery missmatch uri for (username=${username}, host=${host}) from ${(user as IRemoteUser).uri} to ${self.href}`);
|
logger.info(`recovery missmatch uri for (username=${username}, host=${host}) from ${user.uri} to ${self.href}`);
|
||||||
|
|
||||||
// validate uri
|
// validate uri
|
||||||
const uri = new URL(self.href);
|
const uri = new URL(self.href);
|
||||||
|
|
|
@ -95,13 +95,6 @@ export default define(meta, async (ps, me) => {
|
||||||
throw new ApiError(meta.errors.noSuchUser);
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ユーザー情報更新
|
|
||||||
if (Users.isRemoteUser(user)) {
|
|
||||||
if (user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) {
|
|
||||||
resolveUser(user.username, user.host, { }, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Users.pack(user, me, {
|
return await Users.pack(user, me, {
|
||||||
detail: true
|
detail: true
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue