From 629de2d8b7ad6011e17230baeb5bb6f792cec48c Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 16 Feb 2022 14:30:22 +0100 Subject: [PATCH] Make sure "Block" object only stores strings (not array) in "actor|object" * This is done so we can faster search for blocks without using $elemMatch on mongodb --- api/src/activity/federation.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/src/activity/federation.js b/api/src/activity/federation.js index f50a0ac..c7a07b8 100644 --- a/api/src/activity/federation.js +++ b/api/src/activity/federation.js @@ -46,8 +46,15 @@ module.exports = { } if (msg.activity.type === 'Block') { - if (areActorsValid(msg.activity.object, true)) + if (areActorsValid(msg.activity.object, true)) { + if (msg.activity.actor instanceof Array && + msg.activity.actor.length > 0) + msg.activity.actor = msg.activity.actor[0] + if (msg.activity.object instanceof Array && + msg.activity.object.length > 0) + msg.activity.object = msg.activity.object[0] await apex.store.saveObject(msg.activity) + } return true } if (msg.activity.type === 'Undo')