?
This commit is contained in:
parent
5115ff1466
commit
d2ea04fbf2
5 changed files with 24 additions and 14 deletions
|
|
@ -70,14 +70,18 @@ export class AccountMoveService {
|
|||
*/
|
||||
@bindThis
|
||||
public async moveFromLocal(src: LocalUser, dst: LocalUser | RemoteUser): Promise<unknown> {
|
||||
const srcUri = this.userEntityService.getUserUri(src);
|
||||
const dstUri = this.userEntityService.getUserUri(dst);
|
||||
|
||||
// add movedToUri to indicate that the user has moved
|
||||
const update = {} as Partial<User>;
|
||||
const update = {} as Partial<LocalUser>;
|
||||
update.alsoKnownAs = src.alsoKnownAs?.includes(dstUri) ? src.alsoKnownAs : src.alsoKnownAs?.concat([dstUri]) ?? [dstUri];
|
||||
update.movedToUri = dstUri;
|
||||
await this.usersRepository.update(src.id, update);
|
||||
src = Object.assign(src, update);
|
||||
Object.assign(src, update);
|
||||
|
||||
// Update cache
|
||||
this.cacheService.uriPersonCache.set(srcUri, src);
|
||||
|
||||
const srcPerson = await this.apRendererService.renderPerson(src);
|
||||
const updateAct = this.apRendererService.addContext(this.apRendererService.renderUpdate(srcPerson, src));
|
||||
|
|
@ -101,14 +105,13 @@ export class AccountMoveService {
|
|||
to: { id: following.followeeId },
|
||||
})));
|
||||
|
||||
// Move!
|
||||
await this.move(src, dst);
|
||||
await this.postMoveProcess(src, dst);
|
||||
|
||||
return iObj;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async move(src: User, dst: User): Promise<void> {
|
||||
public async postMoveProcess(src: User, dst: User): Promise<void> {
|
||||
// Copy blockings and mutings, and update lists
|
||||
try {
|
||||
await Promise.all([
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ export class ApInboxService {
|
|||
if (!targetUri) return 'skip: invalid activity target';
|
||||
await Promise.all([
|
||||
this.apPersonService.updatePerson(targetUri),
|
||||
this.apPersonService.updatePerson(actor.uri),
|
||||
this.apPersonService.updatePerson(actor.uri), // actor may cached for a day or more
|
||||
]);
|
||||
const [newAccount, oldAccount] = await Promise.all([
|
||||
this.apPersonService.resolvePerson(targetUri),
|
||||
|
|
@ -774,7 +774,7 @@ export class ApInboxService {
|
|||
}
|
||||
|
||||
// Move!
|
||||
await this.accountMoveService.move(oldAccount, newAccount);
|
||||
await this.accountMoveService.postMoveProcess(oldAccount, newAccount);
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ export class InboxProcessorService {
|
|||
|
||||
// HTTP-Signature keyIdを元にDBから取得
|
||||
let authUser: {
|
||||
user: RemoteUser;
|
||||
key: UserPublickey | null;
|
||||
} | null = await this.apDbResolverService.getAuthUserFromKeyId(signature.keyId);
|
||||
user: RemoteUser;
|
||||
key: UserPublickey | null;
|
||||
} | null = await this.apDbResolverService.getAuthUserFromKeyId(signature.keyId);
|
||||
|
||||
// keyIdでわからなければ、activity.actorを元にDBから取得 || activity.actorを元にリモートから取得
|
||||
if (authUser == null) {
|
||||
|
|
|
|||
|
|
@ -350,6 +350,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
//#endregion
|
||||
|
||||
if (Object.keys(updates).length > 0) await this.usersRepository.update(user.id, updates);
|
||||
if (Object.keys(updates).includes('alsoKnownAs')) {
|
||||
this.cacheService.uriPersonCache.set(this.userEntityService.genLocalUserUri(user.id), { ...user, ...updates });
|
||||
}
|
||||
if (Object.keys(profileUpdates).length > 0) await this.userProfilesRepository.update(user.id, profileUpdates);
|
||||
|
||||
const iObj = await this.userEntityService.pack<true, true>(user.id, user, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue