Allow to undo Create activity
This commit is contained in:
parent
210cb57aa5
commit
783453897f
5 changed files with 30 additions and 17 deletions
10
src/remote/activitypub/delete/index.ts
Normal file
10
src/remote/activitypub/delete/index.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import deletePost from './post';
|
||||
|
||||
export default async ({ object }) => {
|
||||
switch (object.$ref) {
|
||||
case 'posts':
|
||||
return deletePost(object);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
13
src/remote/activitypub/delete/post.ts
Normal file
13
src/remote/activitypub/delete/post.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import Post from '../../../models/post';
|
||||
import queue from '../../../queue';
|
||||
|
||||
export default async ({ $id }) => {
|
||||
const promisedDeletion = Post.findOneAndDelete({ _id: $id });
|
||||
|
||||
await new Promise((resolve, reject) => queue.create('db', {
|
||||
type: 'deletePostDependents',
|
||||
id: $id
|
||||
}).delay(65536).save(error => error ? reject(error) : resolve()));
|
||||
|
||||
return promisedDeletion;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue