Set a global limit for the authors concatenation
This commit is contained in:
parent
bcedd025ba
commit
3c68fafd8e
@ -11,7 +11,7 @@ import com.readrops.db.entities.Item
|
||||
import java.io.InputStream
|
||||
|
||||
interface XmlAdapter<T> {
|
||||
|
||||
|
||||
fun fromXml(inputStream: InputStream): T
|
||||
|
||||
companion object {
|
||||
@ -32,6 +32,8 @@ interface XmlAdapter<T> {
|
||||
else -> throw IllegalArgumentException("Unknown RSS type : $type")
|
||||
}
|
||||
}
|
||||
|
||||
const val AUTHORS_MAX = 4
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.readrops.api.localfeed.json
|
||||
|
||||
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
|
||||
import com.readrops.api.utils.DateUtils
|
||||
import com.readrops.api.utils.ParseException
|
||||
import com.readrops.api.utils.nextNullableString
|
||||
@ -99,7 +100,7 @@ class JSONItemsAdapter : JsonAdapter<List<Item>>() {
|
||||
|
||||
// here, nextNullableString doesn't check if authors values are empty
|
||||
return if (authors.filterNot { author -> author.isNullOrEmpty() }.isNotEmpty())
|
||||
authors.filterNot { author -> author.isNullOrEmpty() }.joinToString(limit = 4) else null
|
||||
authors.filterNot { author -> author.isNullOrEmpty() }.joinToString(limit = AUTHORS_MAX) else null
|
||||
}
|
||||
|
||||
private fun validateItem(item: Item) {
|
||||
|
@ -4,6 +4,7 @@ import com.gitlab.mvysny.konsumexml.Names
|
||||
import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
|
||||
import com.gitlab.mvysny.konsumexml.konsumeXml
|
||||
import com.readrops.api.localfeed.XmlAdapter
|
||||
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
|
||||
import com.readrops.api.utils.*
|
||||
import com.readrops.db.entities.Item
|
||||
import java.io.InputStream
|
||||
@ -36,7 +37,7 @@ class RSS1ItemsAdapter : XmlAdapter<List<Item>> {
|
||||
}
|
||||
|
||||
item.guid = item.link
|
||||
if (authors.filterNotNull().isNotEmpty()) item.author = authors.filterNotNull().joinToString(limit = 4)
|
||||
if (authors.filterNotNull().isNotEmpty()) item.author = authors.filterNotNull().joinToString(limit = AUTHORS_MAX)
|
||||
if (item.link == null) item.link = about
|
||||
|
||||
validateItem(item)
|
||||
|
@ -2,6 +2,7 @@ package com.readrops.api.localfeed.rss2
|
||||
|
||||
import com.gitlab.mvysny.konsumexml.*
|
||||
import com.readrops.api.localfeed.XmlAdapter
|
||||
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
|
||||
import com.readrops.api.utils.*
|
||||
import com.readrops.db.entities.Item
|
||||
import java.io.InputStream
|
||||
@ -47,7 +48,7 @@ class RSS2ItemsAdapter : XmlAdapter<List<Item>> {
|
||||
validateItem(item)
|
||||
if (item.guid == null) item.guid = item.link
|
||||
if (item.author == null && creators.filterNotNull().isNotEmpty())
|
||||
item.author = creators.filterNotNull().first()
|
||||
item.author = creators.filterNotNull().joinToString(limit = AUTHORS_MAX)
|
||||
|
||||
if (enclosures.isNotEmpty()) item.imageLink = enclosures.first()
|
||||
else if (mediaContents.isNotEmpty()) item.imageLink = mediaContents.first()
|
||||
|
Loading…
x
Reference in New Issue
Block a user