Add a new key for feeds to set active status
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user