Node.js based forum software built for the modern web
refactor: catch errors
Barış Soner Uşaklıf76a5863288d
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.jsindex 2571244f31..ef2e29369e 100644--- a/src/activitypub/inbox.js+++ b/src/activitypub/inbox.js@@ -28,7 +28,7 @@ function reject(type, object, target, senderType = 'uid', id = 0) {target,object,},- });+ }).catch(err => winston.error(err.stack));}inbox.create = async (req) => {@@ -280,7 +280,7 @@ inbox.follow = async (req) => {const followerRemoteCount = await db.sortedSetCard(`followersRemote:${id}`);await user.setUserField(id, 'followerRemoteCount', followerRemoteCount);- user.onFollow(actor, id);+ await user.onFollow(actor, id);activitypub.send('uid', id, actor, {id: `${nconf.get('url')}/${type}/${id}#activity/accept:follow/${handle}/${Date.now()}`,type: 'Accept',@@ -290,7 +290,7 @@ inbox.follow = async (req) => {actor,object: object.id,},- });+ }).catch(err => winston.error(err.stack));} else if (type === 'category') {const [exists, allowed] = await Promise.all([categories.exists(id),@@ -317,7 +317,7 @@ inbox.follow = async (req) => {actor,object: object.id,},- });+ }).catch(err => winston.error(err.stack));}};diff --git a/src/api/activitypub.js b/src/api/activitypub.jsindex 813436a154..10b62c141e 100644--- a/src/api/activitypub.js+++ b/src/api/activitypub.js@@ -9,7 +9,7 @@*/const nconf = require('nconf');-// const winston = require('winston');+const winston = require('winston');const db = require('../database');const user = require('../user');@@ -164,7 +164,8 @@ activitypubApi.create.note = enabledCheck(async (caller, { pid }) => {await activitypub.send('uid', caller.uid, Array.from(targets), payloads.create);if (followers.length) {setTimeout(() => { // Delay sending to avoid potential race condition- activitypub.send('cid', cid, followers, payloads.announce);+ activitypub.send('cid', cid, followers, payloads.announce)+ .catch(err => winston.error(err.stack));}, 5000);}});