fix references to old user object in ApPersonService.updatePerson
This commit is contained in:
parent
09ef662444
commit
f4e1558424
1 changed files with 12 additions and 11 deletions
|
|
@ -765,9 +765,12 @@ export class ApPersonService implements OnModuleInit {
|
||||||
return `skip: user ${exist.id} is deleted`;
|
return `skip: user ${exist.id} is deleted`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not use "exist" after this point!!
|
||||||
|
const updated = { ...exist, ...updates };
|
||||||
|
|
||||||
if (person.publicKey) {
|
if (person.publicKey) {
|
||||||
const publicKey = new MiUserPublickey({
|
const publicKey = new MiUserPublickey({
|
||||||
userId: exist.id,
|
userId: updated.id,
|
||||||
keyId: person.publicKey.id,
|
keyId: person.publicKey.id,
|
||||||
keyPem: person.publicKey.publicKeyPem,
|
keyPem: person.publicKey.publicKeyPem,
|
||||||
});
|
});
|
||||||
|
|
@ -781,7 +784,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
this.publicKeyByUserIdCache.set(publicKey.userId, publicKey),
|
this.publicKeyByUserIdCache.set(publicKey.userId, publicKey),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
const existingPublicKey = await this.userPublickeysRepository.findOneBy({ userId: exist.id });
|
const existingPublicKey = await this.userPublickeysRepository.findOneBy({ userId: updated.id });
|
||||||
if (existingPublicKey) {
|
if (existingPublicKey) {
|
||||||
// Delete key
|
// Delete key
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|
@ -800,7 +803,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
_description = this.apMfmService.htmlToMfm(truncate(person.summary, this.config.maxRemoteBioLength), person.tag);
|
_description = this.apMfmService.htmlToMfm(truncate(person.summary, this.config.maxRemoteBioLength), person.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.userProfilesRepository.update({ userId: exist.id }, {
|
await this.userProfilesRepository.update({ userId: updated.id }, {
|
||||||
url,
|
url,
|
||||||
fields,
|
fields,
|
||||||
verifiedLinks,
|
verifiedLinks,
|
||||||
|
|
@ -813,27 +816,25 @@ export class ApPersonService implements OnModuleInit {
|
||||||
listenbrainz: person.listenbrainz ?? null,
|
listenbrainz: person.listenbrainz ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: exist.id });
|
this.globalEventService.publishInternalEvent('remoteUserUpdated', { id: updated.id });
|
||||||
|
|
||||||
// 該当ユーザーが既にフォロワーになっていた場合はFollowingもアップデートする
|
// 該当ユーザーが既にフォロワーになっていた場合はFollowingもアップデートする
|
||||||
if (exist.inbox !== person.inbox || exist.sharedInbox !== (person.sharedInbox ?? person.endpoints?.sharedInbox)) {
|
if (updated.inbox !== person.inbox || updated.sharedInbox !== (person.sharedInbox ?? person.endpoints?.sharedInbox)) {
|
||||||
await this.followingsRepository.update(
|
await this.followingsRepository.update(
|
||||||
{ followerId: exist.id },
|
{ followerId: updated.id },
|
||||||
{
|
{
|
||||||
followerInbox: person.inbox,
|
followerInbox: person.inbox,
|
||||||
followerSharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox ?? null,
|
followerSharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox ?? null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.cacheService.refreshFollowRelationsFor(exist.id);
|
await this.cacheService.refreshFollowRelationsFor(updated.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ハッシュタグ更新
|
// ハッシュタグ更新
|
||||||
await this.queueService.createUpdateUserTagsJob(exist.id);
|
await this.queueService.createUpdateUserTagsJob(updated.id);
|
||||||
|
|
||||||
await this.updateFeaturedLazy(exist);
|
await this.updateFeaturedLazy(updated);
|
||||||
|
|
||||||
const updated = { ...exist, ...updates };
|
|
||||||
|
|
||||||
// 移行処理を行う
|
// 移行処理を行う
|
||||||
if (updated.movedAt && (
|
if (updated.movedAt && (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue