Skip to content

Commit 341ae00

Browse files
committed
feat: add methods to handle feeds with takedown status and remove associated items
1 parent 40ffac3 commit 341ae00

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/services/archiver.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,34 @@ export class ArchiverService {
113113
await this.processItems(items, archivedStatus);
114114
}
115115

116+
async getFeedsWithTakedownStatus(): Promise<Feed[]> {
117+
return this.feedRepositoryRead.find({
118+
where: {
119+
feed_flag_status: {
120+
id: FeedFlagStatusStatusEnum.Takedown,
121+
},
122+
},
123+
relations: ['channel', 'channel.items', 'feed_flag_status'],
124+
});
125+
}
126+
127+
async removeAllItemsForTakedownFeeds(): Promise<void> {
128+
const feeds = await this.getFeedsWithTakedownStatus();
129+
for (const feed of feeds) {
130+
const channel = feed.channel;
131+
if (!channel || !channel.items || channel.items.length === 0) {
132+
continue;
133+
}
134+
const itemIds = channel.items.map(item => item.id);
135+
if (itemIds.length > 0) {
136+
await this.itemRepositoryReadWrite.delete(itemIds);
137+
}
138+
}
139+
}
140+
116141
async archiveAll(): Promise<void> {
117142
await this.processPendingArchiveFeeds();
118143
await this.processPendingArchiveItems();
144+
await this.removeAllItemsForTakedownFeeds();
119145
}
120146
}

0 commit comments

Comments
 (0)