feat: リモートからユーザー削除が飛んできたら削除するように (#7768)
* Delete Actor * Update src/remote/activitypub/kernel/delete/actor.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
cc75620976
commit
608ff73907
2 changed files with 28 additions and 1 deletions
26
src/remote/activitypub/kernel/delete/actor.ts
Normal file
26
src/remote/activitypub/kernel/delete/actor.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { apLogger } from '../../logger';
|
||||
import { createDeleteAccountJob } from '@/queue';
|
||||
import { IRemoteUser } from '@/models/entities/user';
|
||||
import { Users } from '@/models/index';
|
||||
|
||||
const logger = apLogger;
|
||||
|
||||
export async function deleteActor(actor: IRemoteUser, uri: string): Promise<string> {
|
||||
logger.info(`Deleting the Actor: ${uri}`);
|
||||
|
||||
if (actor.uri !== uri) {
|
||||
return `skip: delete actor ${actor.uri} !== ${uri}`;
|
||||
}
|
||||
|
||||
if (actor.isDeleted) {
|
||||
logger.info(`skip: already deleted`);
|
||||
}
|
||||
|
||||
const job = await createDeleteAccountJob(actor);
|
||||
|
||||
await Users.update(actor.id, {
|
||||
isDeleted: true,
|
||||
});
|
||||
|
||||
return `ok: queued ${job.name} ${job.id}`;
|
||||
}
|
|
@ -2,6 +2,7 @@ import deleteNote from './note';
|
|||
import { IRemoteUser } from '@/models/entities/user';
|
||||
import { IDelete, getApId, isTombstone, IObject, validPost, validActor } from '../../type';
|
||||
import { toSingle } from '@/prelude/array';
|
||||
import { deleteActor } from './actor';
|
||||
|
||||
/**
|
||||
* 削除アクティビティを捌きます
|
||||
|
@ -41,7 +42,7 @@ export default async (actor: IRemoteUser, activity: IDelete): Promise<string> =>
|
|||
if (validPost.includes(formarType)) {
|
||||
return await deleteNote(actor, uri);
|
||||
} else if (validActor.includes(formarType)) {
|
||||
return `Delete Actor is not implanted`;
|
||||
return await deleteActor(actor, uri);
|
||||
} else {
|
||||
return `Unknown type ${formarType}`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue