From 7a60a672d4f59185825f94d1270ec74c38f6400e Mon Sep 17 00:00:00 2001 From: matty Date: Sun, 6 Jul 2025 02:58:50 +0000 Subject: [PATCH] little more error checking/correction/QOL --- src/main.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 546ab6a..eceffe3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -126,15 +126,19 @@ const recordPendingResponse = async (notification: Notification) => { } }; -const isFromWhitelistedDomain = (fqn: string): boolean => { +const isFromWhitelistedDomain = async ( + notification: Notification +): Promise => { try { - const domain = fqn.split("@")[1]; + const domain = notification.status.account.fqn.split("@")[1]; if (envConfig.whitelistedDomains.includes(domain)) { return true; } console.log( `Rejecting prompt request from non-whitelisted domain: ${domain}` ); + // delete the notification so we don't keep trying to fetch it + await deleteNotification(notification); return false; } catch (error: any) { console.error(`Error with domain check: ${error.message}`); @@ -153,10 +157,7 @@ const generateOllamaRequest = async ( !notification.status.account.bot && // sanity check, sort of notification.type === "mention" ) { - if ( - whitelistOnly && - !isFromWhitelistedDomain(notification.status.account.fqn) - ) { + if (whitelistOnly && !(await isFromWhitelistedDomain(notification))) { return; } if (await alreadyRespondedTo(notification)) {