mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 17:00:19 +01:00
?
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, {
|
||||
|
|
|
@ -5,7 +5,7 @@ import rndstr from 'rndstr';
|
|||
import { loadConfig } from '@/config.js';
|
||||
import { User, UsersRepository } from '@/models/index.js';
|
||||
import { jobQueue } from '@/boot/common.js';
|
||||
import { uploadFile, signup, startServer, initTestDb, api, sleep } from '../utils.js';
|
||||
import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js';
|
||||
import type { INestApplicationContext } from '@nestjs/common';
|
||||
|
||||
describe('Account Move', () => {
|
||||
|
@ -346,9 +346,13 @@ describe('Account Move', () => {
|
|||
});
|
||||
|
||||
test('A locked account automatically accept the follow request if it had already accepted the old account.', async () => {
|
||||
await api('/following/create', {
|
||||
userId: frank.id,
|
||||
}, bob);
|
||||
await successfulApiCall({
|
||||
endpoint: '/following/create',
|
||||
parameters: {
|
||||
userId: frank.id,
|
||||
},
|
||||
user: bob,
|
||||
});
|
||||
const followers = await api('/users/followers', {
|
||||
userId: frank.id,
|
||||
}, frank);
|
||||
|
|
Loading…
Reference in a new issue