Add a new key for feeds to set active status

This commit is contained in:
Logan Cusano
2024-09-21 11:36:02 -04:00
parent 33680209ba
commit dfb2765f39
3 changed files with 23 additions and 2 deletions

View File

@@ -71,6 +71,22 @@ export const updateFeedByLink = async (link, updatedFields) => {
}
};
// Wrapper for deactivating a feed by link
export const deactivateFeedByLink = async (link) => {
try {
const updatedCount = await updateDocumentByField(
feedCollectionName,
"link",
link,
[{'active':false}]
);
return updatedCount;
} catch (error) {
log.ERROR("Error deleting feed by link:", error);
throw error;
}
};
// Wrapper for deleting a feed by link
export const deleteFeedByLink = async (link) => {
try {

View File

@@ -51,6 +51,10 @@ export const updateFeeds = async (client) => {
const sourcePromiseArray = records.map(async (source) => {
log.DEBUG("Processing source:", source.title);
// Check if the feed is active
if (!source.active) {
return
}
try {
const parsedFeed = await parser.parseURL(source.link);

View File

@@ -3,7 +3,7 @@ const log = new DebugBuilder("server", "sourceManager");
import {
createFeed,
getFeedByLink,
deleteFeedByLink,
deactivateFeedByLink,
} from "../modules/mongo-wrappers/mongoFeedsWrappers.mjs";
class SourceManager {
@@ -48,7 +48,7 @@ class SourceManager {
return;
}
const results = await deleteFeedByLink(sourceURL);
const results = await deactivateFeedByLink(sourceURL);
if (!results) {
log.WARN(`Failed to remove source: ${sourceURL}`);
return;
@@ -70,6 +70,7 @@ class SourceManager {
category,
guild_id: guildId,
channel_id: channelId,
active: true
};
const record = await createFeed(feed);
log.DEBUG("Source added:", record);