Skip to content
Open
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
31 changes: 15 additions & 16 deletions app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ import com.google.gson.Gson
import com.nextcloud.client.account.User
import com.nextcloud.client.account.UserAccountManager
import com.nextcloud.client.integrations.deck.DeckApi
import com.nextcloud.common.NextcloudClient
import com.nextcloud.common.OkHttpMethodBase
import com.nextcloud.operations.DeleteMethod
import com.nextcloud.operations.GetMethod
import com.nextcloud.operations.PutMethod
import com.nextcloud.operations.Utf8PostMethod
import com.owncloud.android.R
import com.owncloud.android.datamodel.DecryptedPushMessage
import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.OwnCloudClientFactory
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.lib.resources.notifications.DeleteNotificationRemoteOperation
import com.owncloud.android.lib.resources.notifications.GetNotificationRemoteOperation
Expand All @@ -42,12 +48,7 @@ import com.owncloud.android.ui.notifications.NotificationUtils
import com.owncloud.android.utils.PushUtils
import com.owncloud.android.utils.theme.ViewThemeUtils
import dagger.android.AndroidInjection
import org.apache.commons.httpclient.HttpMethod
import org.apache.commons.httpclient.HttpStatus
import org.apache.commons.httpclient.methods.DeleteMethod
import org.apache.commons.httpclient.methods.GetMethod
import org.apache.commons.httpclient.methods.PutMethod
import org.apache.commons.httpclient.methods.Utf8PostMethod
import java.io.IOException
import java.security.GeneralSecurityException
import java.security.PrivateKey
Expand Down Expand Up @@ -241,8 +242,7 @@ class NotificationWork constructor(
val result = GetNotificationRemoteOperation(decryptedPushMessage.nid)
.execute(client)
if (result.isSuccess) {
val notification = result.resultData
sendNotification(notification, account)
sendNotification(result.resultData, account)
}
} catch (e: Exception) {
Log_OC.e(this, "Error creating account", e)
Expand Down Expand Up @@ -318,18 +318,17 @@ class NotificationWork constructor(
}

@Suppress("ReturnCount") // legacy code
private fun executeAction(actionType: String, actionLink: String, client: OwnCloudClient): Int {
val method: HttpMethod
private fun executeAction(actionType: String, actionLink: String, client: NextcloudClient): Int {
val method: OkHttpMethodBase
method = when (actionType) {
"GET" -> GetMethod(actionLink)
"POST" -> Utf8PostMethod(actionLink)
"DELETE" -> DeleteMethod(actionLink)
"PUT" -> PutMethod(actionLink)
"GET" -> GetMethod(actionLink, true)
"POST" -> Utf8PostMethod(actionLink, true, null)
"DELETE" -> DeleteMethod(actionLink, true)
"PUT" -> PutMethod(actionLink, true, null)
else -> return 0 // do nothing
}
method.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE)
try {
return client.executeMethod(method)
return client.execute(method)
} catch (e: IOException) {
Log_OC.e(TAG, "Execution of notification action failed: $e")
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
buildscript {
ext {
androidLibraryVersion ="f174c1ee78"
androidLibraryVersion ="2df66e2babe773c2de3a6819592929aa8a6c94ff"
androidPluginVersion = '8.7.3'
androidxMediaVersion = '1.4.1'
androidxTestVersion = "1.6.1"
Expand Down
Loading