separation of concerns
This commit is contained in:
@ -2,7 +2,6 @@ import striptags from "striptags";
|
||||
import { prisma } from "./main.js";
|
||||
import { envConfig } from "./main.js";
|
||||
import { Notification } from "../types.js";
|
||||
import { deleteNotification } from "./api.js";
|
||||
|
||||
const trimInputData = (input: string): string => {
|
||||
const strippedInput = striptags(input);
|
||||
@ -26,9 +25,7 @@ const recordPendingResponse = async (notification: Notification) => {
|
||||
}
|
||||
};
|
||||
|
||||
const isFromWhitelistedDomain = async (
|
||||
notification: Notification
|
||||
): Promise<boolean> => {
|
||||
const isFromWhitelistedDomain = (notification: Notification): boolean => {
|
||||
try {
|
||||
const domain = notification.status.account.fqn.split("@")[1];
|
||||
if (envConfig.whitelistedDomains.includes(domain)) {
|
||||
@ -37,8 +34,6 @@ const isFromWhitelistedDomain = async (
|
||||
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}`);
|
||||
|
Reference in New Issue
Block a user