Skip to content

Commit 70178af

Browse files
committed
update feed only if nextUpdateTime has been reached
Signed-off-by: Benjamin Brahmer <[email protected]>
1 parent adee7d0 commit 70178af

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the
88
## [25.x.x]
99
### Changed
1010
- API add new field to Feed that indicates when the next update will be done "nextUpdateTime" (#2993)
11+
- Change logic to update feed only if the nextUpdateTime has been reached ()
1112

1213
### Fixed
1314

lib/Service/FeedServiceV2.php

+13
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ public function fetch(Entity $feed): Entity
276276
return $feed;
277277
}
278278

279+
$nextUpdateTime = $feed->getNextUpdateTime();
280+
$currentTime = time();
281+
$tolerance = 10 * 60; // 10 minutes tolerance
282+
283+
if ($nextUpdateTime !== null && ($currentTime + $tolerance) < $nextUpdateTime) {
284+
$this->logger->info('Feed update skipped. Next update time not reached.', [
285+
'feedUrl' => $feed->getUrl(),
286+
'nextUpdateTime' => $nextUpdateTime,
287+
'currentTime' => $currentTime,
288+
]);
289+
return $feed;
290+
}
291+
279292
// for backwards compatibility it can be that the location is not set
280293
// yet, if so use the url
281294
$location = $feed->getLocation() ?? $feed->getUrl();

0 commit comments

Comments
 (0)