summaryrefslogtreecommitdiff
path: root/src/queue/processors/http/deliver-post.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-04-05 01:05:50 +0900
committerGitHub <noreply@github.com>2018-04-05 01:05:50 +0900
commit87d592c9c46e252edfd44d98f3ca1ec981c1e86f (patch)
tree78800c67f3238c0fa506c22b8473ba7a8705e77c /src/queue/processors/http/deliver-post.ts
parentMerge pull request #1394 from akihikodaki/duplicate (diff)
parentLet unhandled rejection handler handle rejections in jobs (diff)
downloadmisskey-87d592c9c46e252edfd44d98f3ca1ec981c1e86f.tar.gz
misskey-87d592c9c46e252edfd44d98f3ca1ec981c1e86f.tar.bz2
misskey-87d592c9c46e252edfd44d98f3ca1ec981c1e86f.zip
Merge pull request #1395 from akihikodaki/duplicate
Let unhandled rejection handler handle rejections in jobs
Diffstat (limited to 'src/queue/processors/http/deliver-post.ts')
-rw-r--r--src/queue/processors/http/deliver-post.ts28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/queue/processors/http/deliver-post.ts b/src/queue/processors/http/deliver-post.ts
index e743fc5f68..8107c8bf74 100644
--- a/src/queue/processors/http/deliver-post.ts
+++ b/src/queue/processors/http/deliver-post.ts
@@ -5,17 +5,23 @@ import renderCreate from '../../../remote/activitypub/renderer/create';
import renderNote from '../../../remote/activitypub/renderer/note';
import request from '../../../remote/request';
-export default async ({ data }) => {
- const promisedTo = User.findOne({ _id: data.toId }) as Promise<IRemoteUser>;
- const [from, post] = await Promise.all([
- User.findOne({ _id: data.fromId }),
- Post.findOne({ _id: data.postId })
- ]);
- const note = await renderNote(from, post);
- const to = await promisedTo;
- const create = renderCreate(note);
+export default async ({ data }, done) => {
+ try {
+ const promisedTo = User.findOne({ _id: data.toId }) as Promise<IRemoteUser>;
+ const [from, post] = await Promise.all([
+ User.findOne({ _id: data.fromId }),
+ Post.findOne({ _id: data.postId })
+ ]);
+ const note = await renderNote(from, post);
+ const to = await promisedTo;
+ const create = renderCreate(note);
- create['@context'] = context;
+ create['@context'] = context;
- return request(from, to.account.inbox, create);
+ await request(from, to.account.inbox, create);
+ } catch (error) {
+ done(error);
+ }
+
+ done();
};