}
fun syncAll() {
- SyncJob({ Database.getAllFeeds()}).sync() {
+ SyncJob(settings, { Database.getAllFeeds()}).sync() {
window?.reload()
}
}
fun syncCurrent() {
window?.feedList?.currentFeed?.let {
- SyncJob({ Database.getFeed(it.id)?.let { mutableListOf(it)} ?: mutableListOf() }).sync() {
+ SyncJob(settings, { Database.getFeed(it.id)?.let { mutableListOf(it)} ?: mutableListOf() }).sync() {
window?.reload()
}
}
try {
val pending = Database.getPendingFeeds(settings.defaultRefreshInterval)
if(!pending.isEmpty()) {
- SyncJob { pending }.syncBlocking()
+ SyncJob(settings, { pending }).syncBlocking()
GlobalScope.launch(ToolkitDispatcher) {
window!!.sourceList.invalidateCache()
window!!.sourceList.reloadStatus()
val id = rs.getInt("feed_id")
val name = rs.getString("name")
val url = rs.getString("url")
+ val maxItemAge = rs.getInt("max_item_age")
val authUser = rs.getString("auth_user")
val authPassword = rs.getString("auth_password")
val certPath = rs.getString("certpath")
val feed = Feed(id, name, url)
+ feed.maxItemAge = maxItemAge
feed.user = authUser
feed.password = authPassword
feed.certpath = certPath
val id = rs.getInt("feed_id")
val name = rs.getString("name")
val url = rs.getString("url")
+ val maxItemAge = rs.getInt("max_item_age")
val authUser = rs.getString("auth_user")
val authPassword = rs.getString("auth_password")
val certPath = rs.getString("certpath")
feed = Feed(id, name, url)
+ feed.maxItemAge = maxItemAge
feed.user = authUser
feed.password = authPassword
feed.certpath = certPath
val id = rs.getInt("feed_id")
val name = rs.getString("name")
val url = rs.getString("url")
+ val maxItemAge = rs.getInt("max_item_age")
val authUser = rs.getString("auth_user")
val authPassword = rs.getString("auth_password")
val certPath = rs.getString("certpath")
feed.user = authUser
feed.password = authPassword
feed.certpath = certPath
+ feed.maxItemAge = maxItemAge
feeds.add(feed)
}
}
val evt = event.subListEventData
val feedIndex = evt.rowIndex
if(evt.sublistIndex >= 0) {
- SyncJob({
+ SyncJob(App.settings,{
if(feedIndex >= 0) {
val feed = Database.getFeed(sourceList.groups[evt.sublistIndex].feeds[feedIndex].id)
feed?.let { mutableListOf(it)} ?: mutableListOf()
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
+import java.time.Duration
+import java.time.Instant
-class SyncJob(feeds: () -> List<Feed>) {
+class SyncJob(settings: Settings, feeds: () -> List<Feed>) {
+ val settings = settings
val getFeeds: () -> List<Feed> = feeds
var completionContext = ToolkitDispatcher
println("Fetched feed: ${syndFeed.title}")
syndFeed.entries.forEach { entry ->
//println(" ${entry.title} - ${entry.link}")
+ if(feed.maxItemAge >= 0) {
+ val max_age = if(feed.maxItemAge == 0) settings.maxItemAge else feed.maxItemAge
+ if(max_age > 0) {
+ val date = entry.updatedDate ?: entry.publishedDate
+ date?.let {
+ val age = Duration.between(it.toInstant(), Instant.now()).toDays()
+ if(age > max_age) {
+ //println("Item too old, skipping: ${entry.title} date: ${it}")
+ return@forEach
+ }
+ }
+ }
+ }
val item = Item(0)
item.feedId = feed.id