little more error checking/correction/QOL

This commit is contained in:
2025-07-06 02:58:50 +00:00
parent 419285487a
commit 7a60a672d4

View File

@ -126,15 +126,19 @@ const recordPendingResponse = async (notification: Notification) => {
}
};
const isFromWhitelistedDomain = (fqn: string): boolean => {
const isFromWhitelistedDomain = async (
notification: Notification
): Promise<boolean> => {
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)) {