24 lines
711 B
JavaScript
24 lines
711 B
JavaScript
/**
|
|
* Helper method to BLOCK discordbot from scraping API links
|
|
* This is a bit of a hack until we process event links from UI instead of raw API
|
|
*/
|
|
exports.shouldBlockRequest = (event) => {
|
|
let headers = event?.request?.headers;
|
|
let userAgentString = "";
|
|
|
|
if (headers && headers['user-agent']) {
|
|
userAgentString = headers['user-agent'];
|
|
}
|
|
|
|
console.log("[BlockUserAgent] got useragent", userAgentString);
|
|
|
|
let blockList = ["Discord", "bot", "facebook"];
|
|
|
|
console.log("[BlockUserAgent] blocked useragents are", blockList);
|
|
|
|
let willBlock = blockList.some(term => userAgentString.includes(term));
|
|
|
|
console.log("[BlockUserAgent] should block request: ", willBlock);
|
|
return willBlock;
|
|
};
|