How skip the fetching process for the Feed Item as soon as article filtering script found that article is older than X days #1147
-
Hello, I wanted to skip fetching process for feed item if the message is created older than 2 days. For that, I managed to get a ChatGPT generated Javascript and reconfigured it for Article filtering as follows: function isDateOlderThanTwoDays(targetDate) {
// Get the current date
const currentDate = new Date();
// Calculate the date that is 2 days ago
const twoDaysAgo = new Date();
twoDaysAgo.setDate(currentDate.getDate() - 2);
// Compare the target date with two days ago
return targetDate < twoDaysAgo;
}
function filterMessage() {
const messageDate = new Date(msg.created); // Replace with your message date
const isOlderThanTwoDays = isDateOlderThanTwoDays(messageDate);
if (isOlderThanTwoDays) {
return MessageObject.Ignore;
}
else {
return MessageObject.Accept;
}
} The script seems to work but the problem is that the fetching process continues from one message to another after ignoring the previous. So, is there any way to kill/skip the fetching process for that certain feed item soon as it is found that the message is older than 2 days? I hope i was able to explain properly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi. There is no "fetching" to stop. When article filters run, the feed/articles are already all downloaded (because they are all contained in one XML feed file). I guess we could add new "MessageObject.IgnoreAndStop" which will also disable filtering of next articles from the same feed and go right to next feed (or exit). |
Beta Was this translation helpful? Give feedback.
Hi.
There is no "fetching" to stop. When article filters run, the feed/articles are already all downloaded (because they are all contained in one XML feed file).
I guess we could add new "MessageObject.IgnoreAndStop" which will also disable filtering of next articles from the same feed and go right to next feed (or exit).