Skip to content

Commit

Permalink
Fix invalid feeds not being enabled on retry
Browse files Browse the repository at this point in the history
  • Loading branch information
synzen committed Dec 5, 2024
1 parent c6a4f13 commit 7d67ed0
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions services/backend-api/src/features/user-feeds/user-feeds.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,23 +989,38 @@ export class UserFeedsService {
getCachedResponse: false,
}
);
feed.disabledCode === UserFeedDisabledCode.FailedRequests;

const isRequestSuccessful =
res.requestStatus === FeedFetcherFetchStatus.Success;
let canBeEnabled = isRequestSuccessful;

if (
isRequestSuccessful &&
feed.disabledCode === UserFeedDisabledCode.InvalidFeed
) {
const res2 = await this.getFeedArticleProperties({
feed,
url: feed.url,
});

canBeEnabled =
isRequestSuccessful &&
res2.requestStatus === GetArticlesResponseRequestStatus.Success;
}

await this.userFeedModel
.findByIdAndUpdate(feed._id, {
$set: {
lastManualRequestAt: requestDate,
healthStatus:
res.requestStatus === FeedFetcherFetchStatus.Success
? UserFeedHealthStatus.Ok
: feed.healthStatus,
healthStatus: isRequestSuccessful
? UserFeedHealthStatus.Ok
: feed.healthStatus,
},
...(res.requestStatus === FeedFetcherFetchStatus.Success &&
feed.disabledCode === UserFeedDisabledCode.FailedRequests && {
$unset: {
disabledCode: "",
},
}),
...(canBeEnabled && {
$unset: {
disabledCode: "",
},
}),
})
.lean();

Expand Down

0 comments on commit 7d67ed0

Please sign in to comment.