Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Nov 30, 2024
1 parent 420dfc1 commit 9bff73e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions api/src/main/java/com/readrops/api/services/Credentials.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ abstract class Credentials(val authorization: String?, val url: String) {
companion object {
fun toCredentials(account: Account): Credentials {
val endPoint = getEndPoint(account.type!!).removePrefix("/")
var accountUrl = account.url!!
if (!accountUrl.endsWith("/")) {
accountUrl += "/"
}

return when (account.type) {
AccountType.NEXTCLOUD_NEWS -> NextcloudNewsCredentials(account.login, account.password, accountUrl + endPoint)
AccountType.FRESHRSS -> FreshRSSCredentials(account.token, accountUrl + endPoint)
AccountType.FEVER -> FeverCredentials(account.login, account.password, accountUrl + endPoint)
AccountType.NEXTCLOUD_NEWS -> NextcloudNewsCredentials(account.login, account.password, account.url + endPoint)
AccountType.FRESHRSS -> FreshRSSCredentials(account.token, account.url + endPoint)
AccountType.FEVER -> FeverCredentials(account.login, account.password, account.url + endPoint)
else -> throw IllegalArgumentException("Unknown account type")
}
}
Expand Down

0 comments on commit 9bff73e

Please sign in to comment.