Allow modifying source filters #198
@ -642,14 +642,13 @@ class SelfossApi(
|
||||
): SuccessResponse =
|
||||
maybeResponse(
|
||||
if (appSettingsService.getApiVersion() > 1) {
|
||||
createSource("tags[]", title, url, spout, tags, filter)
|
||||
createSource(title, url, spout, tags, filter)
|
||||
} else {
|
||||
createSource("tags", title, url, spout, tags, filter)
|
||||
createSourceOld(title, url, spout, tags)
|
||||
|
||||
},
|
||||
)
|
||||
|
||||
private suspend fun createSource(
|
||||
tagsParamName: String,
|
||||
title: String,
|
||||
url: String,
|
||||
spout: String,
|
||||
@ -668,7 +667,47 @@ class SelfossApi(
|
||||
append("url", url)
|
||||
append("spout", spout)
|
||||
append("filter", filter)
|
||||
append(tagsParamName, tags)
|
||||
append("tags[]", tags)
|
||||
},
|
||||
block = {
|
||||
if (appSettingsService
|
||||
.getBasicUserName()
|
||||
.isNotEmpty() &&
|
||||
appSettingsService.getBasicPassword().isNotEmpty()
|
||||
) {
|
||||
headers {
|
||||
append(
|
||||
HttpHeaders.Authorization,
|
||||
constructBasicAuthValue(
|
||||
BasicAuthCredentials(
|
||||
username = appSettingsService.getBasicUserName(),
|
||||
password = appSettingsService.getBasicPassword(),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
private suspend fun createSourceOld(
|
||||
title: String,
|
||||
url: String,
|
||||
spout: String,
|
||||
tags: String,
|
||||
): HttpResponse? =
|
||||
client.tryToSubmitForm(
|
||||
url = url("/source"),
|
||||
formParameters =
|
||||
Parameters.build {
|
||||
if (!shouldHavePostLogin()) {
|
||||
append("username", appSettingsService.getUserName())
|
||||
append("password", appSettingsService.getPassword())
|
||||
}
|
||||
append("title", title)
|
||||
append("url", url)
|
||||
append("spout", spout)
|
||||
append("tags", tags)
|
||||
},
|
||||
block = {
|
||||
if (appSettingsService
|
||||
@ -701,15 +740,14 @@ class SelfossApi(
|
||||
): SuccessResponse =
|
||||
maybeResponse(
|
||||
if (appSettingsService.getApiVersion() > 1) {
|
||||
updateSource(id, "tags[]", title, url, spout, tags, filter)
|
||||
updateSource(id, title, url, spout, tags, filter)
|
||||
} else {
|
||||
updateSource(id, "tags", title, url, spout, tags, filter)
|
||||
updateSourceOld(id, title, url, spout, tags)
|
||||
AmineB
commented
Same here. Same here.
|
||||
},
|
||||
)
|
||||
|
||||
private suspend fun updateSource(
|
||||
id: Int,
|
||||
tagsParamName: String,
|
||||
title: String,
|
||||
url: String,
|
||||
spout: String,
|
||||
@ -727,7 +765,7 @@ class SelfossApi(
|
||||
append("title", title)
|
||||
append("url", url)
|
||||
append("spout", spout)
|
||||
append(tagsParamName, tags)
|
||||
append("tags[]", tags)
|
||||
append("filter", filter)
|
||||
},
|
||||
block = {
|
||||
@ -751,6 +789,47 @@ class SelfossApi(
|
||||
},
|
||||
)
|
||||
|
||||
private suspend fun updateSourceOld(
|
||||
id: Int,
|
||||
title: String,
|
||||
url: String,
|
||||
spout: String,
|
||||
tags: String,
|
||||
): HttpResponse? =
|
||||
client.tryToSubmitForm(
|
||||
url = url("/source/$id"),
|
||||
formParameters =
|
||||
Parameters.build {
|
||||
if (!shouldHavePostLogin()) {
|
||||
append("username", appSettingsService.getUserName())
|
||||
append("password", appSettingsService.getPassword())
|
||||
}
|
||||
append("title", title)
|
||||
append("url", url)
|
||||
append("spout", spout)
|
||||
append("tags", tags)
|
||||
},
|
||||
block = {
|
||||
if (appSettingsService
|
||||
.getBasicUserName()
|
||||
.isNotEmpty() &&
|
||||
appSettingsService.getBasicPassword().isNotEmpty()
|
||||
) {
|
||||
headers {
|
||||
append(
|
||||
HttpHeaders.Authorization,
|
||||
constructBasicAuthValue(
|
||||
BasicAuthCredentials(
|
||||
username = appSettingsService.getBasicUserName(),
|
||||
password = appSettingsService.getBasicPassword(),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
suspend fun deleteSource(id: Int): SuccessResponse =
|
||||
maybeResponse(
|
||||
client.tryToDelete(url("/source/$id")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user
There's no need to create a new method.
In the
createSouce
method, you could add an optional parameterfilter
and add it to the form parameters with something like