Allow to undo Create activity
This commit is contained in:
parent
210cb57aa5
commit
783453897f
@ -1,5 +1,5 @@
|
|||||||
import create from '../../create';
|
import create from '../create';
|
||||||
import deletePost from './post';
|
import deleteObject from '../delete';
|
||||||
|
|
||||||
export default async (resolver, actor, activity) => {
|
export default async (resolver, actor, activity) => {
|
||||||
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
||||||
@ -14,10 +14,7 @@ export default async (resolver, actor, activity) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (result.object.$ref) {
|
await deleteObject(result);
|
||||||
case 'posts':
|
|
||||||
await deletePost(result.object);
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return null;
|
return null;
|
@ -1,10 +0,0 @@
|
|||||||
import Post from '../../../../models/post';
|
|
||||||
import queue from '../../../../queue';
|
|
||||||
|
|
||||||
export default ({ $id }) => Promise.all([
|
|
||||||
Post.findOneAndDelete({ _id: $id }),
|
|
||||||
new Promise((resolve, reject) => queue.create('db', {
|
|
||||||
type: 'deletePostDependents',
|
|
||||||
id: $id
|
|
||||||
}).delay(65536).save(error => error ? reject(error) : resolve()))
|
|
||||||
]);
|
|
@ -1,4 +1,5 @@
|
|||||||
import act from '../../act';
|
import act from '../../act';
|
||||||
|
import deleteObject from '../../delete';
|
||||||
import unfollow from './unfollow';
|
import unfollow from './unfollow';
|
||||||
import Resolver from '../../resolver';
|
import Resolver from '../../resolver';
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ export default async (resolver: Resolver, actor, activity): Promise<void> => {
|
|||||||
await Promise.all(results.map(async promisedResult => {
|
await Promise.all(results.map(async promisedResult => {
|
||||||
const result = await promisedResult;
|
const result = await promisedResult;
|
||||||
|
|
||||||
if (result === null) {
|
if (result === null || await deleteObject(result) !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,4 +22,6 @@ export default async (resolver: Resolver, actor, activity): Promise<void> => {
|
|||||||
await unfollow(result.object);
|
await unfollow(result.object);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
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…
Reference in New Issue
Block a user