From 876ac87ebb579164cfb24352be5e1481200d4ebe Mon Sep 17 00:00:00 2001 From: fenwick67 Date: Sun, 13 Oct 2024 15:30:11 -0400 Subject: [PATCH] add nobot support --- lib/convertv2.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/convertv2.js b/lib/convertv2.js index ba3f839..5dd4ba4 100644 --- a/lib/convertv2.js +++ b/lib/convertv2.js @@ -47,6 +47,10 @@ module.exports = async function (opts) { // get user, then outbox, then feed user = await apGet(userUrl,24 * hour); + console.log(JSON.stringify(user,null,2)) + if (userNobot(user)){ + throw new Error("this user has #nobot in their profile. Add #yesMastofeed or #mastofeed to your profile if you want to use mastofeed and keep #nobot") + } isIndex = true; var outbox = await apGet(user.outbox, 1 * hour); @@ -73,8 +77,14 @@ module.exports = async function (opts) { function userNobot(user){ let lowerSummary = (user.summary||"").toLowerCase(); - let nobot = lowerSummary.indexOf('#nobot') > -1; - let yesmastofeed = lowerSummary.indexOf('#mastofeed') > -1 || lowerSummary.indexOf('#yesmastofeed') > -1 + let nobot = lowerSummary.indexOf('nobot') > -1; + let yesmastofeed = lowerSummary.indexOf('mastofeed') > -1 || lowerSummary.indexOf('yesmastofeed') > -1; + if (Array.isArray(user.tag)){ + let nobotTag = !!user.tag.find(t=>t.name&&t.name.toLowerCase()=="#nobot"); + let yesmastofeedTag = !!user.tag.find(t=>t.name&&(t.name.toLowerCase()=="#yesmastofeed" || t.name.toLowerCase()=="#mastofeed")); + nobot |= nobotTag; + yesmastofeed |= yesmastofeedTag; + } return nobot && !yesmastofeed; }