Implement Delete activity
This commit is contained in:
parent
5bcb4b1dde
commit
210cb57aa5
6 changed files with 81 additions and 9 deletions
24
src/remote/activitypub/act/delete/index.ts
Normal file
24
src/remote/activitypub/act/delete/index.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import create from '../../create';
|
||||
import deletePost from './post';
|
||||
|
||||
export default async (resolver, actor, activity) => {
|
||||
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
const results = await create(resolver, actor, activity.object);
|
||||
|
||||
await Promise.all(results.map(async promisedResult => {
|
||||
const result = await promisedResult;
|
||||
if (result === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (result.object.$ref) {
|
||||
case 'posts':
|
||||
await deletePost(result.object);
|
||||
}
|
||||
}));
|
||||
|
||||
return null;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue