Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdk = 26
targetSdk = 36
versionCode = 4591
versionName = "0.45.91"
versionCode = 4592
versionName = "0.45.92"
ndkVersion = '26.3.11579264'
vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class UploadToShelfService @Inject constructor(
private suspend fun checkIfUserExists(apiInterface: ApiInterface, header: String, model: RealmUser): Boolean {
try {
val res = apiInterface.getJsonObject(header, "${replacedUrl(model)}/_users/org.couchdb.user:${model.name}")
val exists = res?.body() != null
val exists = res.body() != null
return exists
} catch (e: Exception) {
e.printStackTrace()
Expand All @@ -143,7 +143,7 @@ class UploadToShelfService @Inject constructor(
val obj = model.serialize()
val createResponse = apiInterface.putDoc(null, "application/json", "${replacedUrl(model)}/_users/org.couchdb.user:${model.name}", obj)

if (createResponse?.isSuccessful == true) {
if (createResponse.isSuccessful) {
val id = createResponse.body()?.get("id")?.asString
val rev = createResponse.body()?.get("rev")?.asString
model._id = id
Expand Down Expand Up @@ -173,7 +173,7 @@ class UploadToShelfService @Inject constructor(
val header = "Basic ${Base64.encodeToString(("${model.name}:${password}").toByteArray(), Base64.NO_WRAP)}"
val fetchDataResponse = apiInterface.getJsonObject(header, "${replacedUrl(model)}/_users/${model._id}")

if (fetchDataResponse?.isSuccessful == true) {
if (fetchDataResponse.isSuccessful) {
model.password_scheme = getString("password_scheme", fetchDataResponse.body())
model.derived_key = getString("derived_key", fetchDataResponse.body())
model.salt = getString("salt", fetchDataResponse.body())
Expand All @@ -193,7 +193,7 @@ class UploadToShelfService @Inject constructor(
try {
val latestDocResponse = apiInterface.getJsonObject(header, "${replacedUrl(model)}/_users/org.couchdb.user:${model.name}")

if (latestDocResponse?.isSuccessful == true) {
if (latestDocResponse.isSuccessful) {
val latestRev = latestDocResponse.body()?.get("_rev")?.asString
val obj = model.serialize()
val objMap = obj.entrySet().associate { (key, value) -> key to value }
Expand Down Expand Up @@ -304,7 +304,7 @@ class UploadToShelfService @Inject constructor(
try {
val res = apiInterface.postDoc(UrlUtils.header, "application/json", "${UrlUtils.getUrl()}/health", serialize(pojo))

if (res?.body() != null && res.body()?.has("id") == true) {
if (res.body() != null && res.body()?.has("id") == true) {
val rev = res.body()?.get("rev")?.asString
dbService.executeTransactionAsync { realm ->
val managedPojo = realm.where(RealmHealthExamination::class.java).equalTo("_id", pojo._id).findFirst()
Expand Down Expand Up @@ -342,7 +342,7 @@ class UploadToShelfService @Inject constructor(
serialize(pojo)
)

if (res?.body() != null && res.body()?.has("id") == true) {
if (res.body() != null && res.body()?.has("id") == true) {
val rev = res.body()?.get("rev")?.asString
dbService.executeTransactionAsync { realm ->
val managedPojo = realm.where(RealmHealthExamination::class.java).equalTo("_id", pojo._id).findFirst()
Expand Down Expand Up @@ -385,7 +385,7 @@ class UploadToShelfService @Inject constructor(
unmanagedUsers.forEach { model ->
if (model.id?.startsWith("guest") == true) return@forEach
try {
val jsonDoc = apiInterface.getJsonObject(UrlUtils.header, "${UrlUtils.getUrl()}/shelf/${model._id}")?.body()
val jsonDoc = apiInterface.getJsonObject(UrlUtils.header, "${UrlUtils.getUrl()}/shelf/${model._id}").body()
val myLibs = resourcesRepository.getMyLibIds(model.id ?: "")
val myCourseIds = coursesRepository.getMyCourseIds(model.id ?: "")
val shelfData = dbService.withRealm { backgroundRealm ->
Expand Down Expand Up @@ -429,7 +429,7 @@ class UploadToShelfService @Inject constructor(
if (model != null) {
if (model.id?.startsWith("guest") != true) {
val shelfUrl = "${UrlUtils.getUrl()}/shelf/${model._id}"
val jsonDoc = apiInterface.getJsonObject(UrlUtils.header, shelfUrl)?.body()
val jsonDoc = apiInterface.getJsonObject(UrlUtils.header, shelfUrl).body()
val myLibs = resourcesRepository.getMyLibIds(model.id ?: "")
val myCourseIds = coursesRepository.getMyCourseIds(model.id ?: "")
val shelfObject = dbService.withRealm { realm ->
Expand Down Expand Up @@ -485,7 +485,7 @@ class UploadToShelfService @Inject constructor(
val apiInterface = client.create(ApiInterface::class.java)
try {
val response = apiInterface.getJsonObject(header, "${UrlUtils.getUrl()}/${table}/_security")
if (response?.body() != null) {
if (response.body() != null) {
val jsonObject = response.body()
val members = jsonObject?.getAsJsonObject("members")
val rolesArray: JsonArray = if (members?.has("roles") == true) {
Expand Down