Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Dec 13, 2024
1 parent 4366946 commit 977ff27
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static File extractAsset(String fileName, Context context) throws IOExcep
@After
public void after() {
removeOnClient(client);
removeOnClient(client2);
// removeOnClient(client2);
}

private void removeOnClient(OwnCloudClient client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class NotificationIT : AbstractIT() {
val count = all.resultData.size

// get one
assertTrue(count > 0)
val firstNotification = all.resultData[0]
val first = GetNotificationRemoteOperation(firstNotification.notificationId).execute(nextcloudClient)
assertTrue(first.isSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import okhttp3.RequestBody
* HTTP POST method that uses OkHttp with new NextcloudClient
* UTF8 by default
*/
class PostMethod(
open class PostMethod(
uri: String,
useOcsApiRequestHeader: Boolean,
val body: RequestBody?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class CreateNotificationRemoteOperation(private val userId: String, private val
client.baseUri.toString() + "/ocs/v2.php/apps/notifications/api/v2/admin_notifications/"

try {
val bodyRequest = FormBody
.Builder()
.add("shortMessage", message)
.build()
val bodyRequest =
FormBody
.Builder()
.add("shortMessage", message)
.build()

post = PostMethod(url + userId, true, bodyRequest)
status = client.execute(post)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.resources.notifications;
package com.owncloud.android.lib.resources.notifications

import com.nextcloud.common.NextcloudClient;
import com.nextcloud.operations.DeleteMethod;
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.nextcloud.common.NextcloudClient
import com.nextcloud.operations.DeleteMethod
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 java.io.IOException

/**
* Delete all notification, specified at
Expand All @@ -24,17 +25,17 @@ class DeleteAllNotificationsRemoteOperation : RemoteOperation<Void>() {
var delete: DeleteMethod? = null
val url = client.baseUri.toString() + OCS_ROUTE_LIST_V12_AND_UP
try {
delete = new DeleteMethod(url, true)
delete = DeleteMethod(url, true)

status = client.execute(delete);
String response = delete.getResponseBodyAsString()
status = client.execute(delete)
val response = delete.getResponseBodyAsString()

if (delete.isSuccess()) {
result = new RemoteOperationResult<>(true, delete)
Log_OC.d(this, "Successful response: " + response)
result = RemoteOperationResult(true, delete)
Log_OC.d(this, "Successful response: $response")
} else {
result = new RemoteOperationResult<>(false, delete)
Log_OC.e(this, "Failed response while deleting user notifications ")
result = RemoteOperationResult(false, delete)
Log_OC.e(this, "Failed response while deleting all user notifications")
Log_OC.e(this, "*** status code: $status ;response message: $response")
}
} catch (e: IOException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.resources.notifications;
package com.owncloud.android.lib.resources.notifications

import com.nextcloud.common.NextcloudClient;
import com.nextcloud.operations.DeleteMethod;
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.nextcloud.common.NextcloudClient
import com.nextcloud.operations.DeleteMethod
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 java.io.IOException

/**
* Delete a notification, specified at
Expand Down Expand Up @@ -46,13 +47,8 @@ class DeleteNotificationRemoteOperation(private val id: Int) : RemoteOperation<V
return result
}

private fun isSuccess(status: Int): Boolean {
return status == HttpStatus.SC_OK
}

companion object {
// OCS Route
private const val OCS_ROUTE_LIST_V12_AND_UP =
"/ocs/v2.php/apps/notifications/api/v2/notifications/"
private const val OCS_ROUTE_LIST_V12_AND_UP = "/ocs/v2.php/apps/notifications/api/v2/notifications/"
}
}

0 comments on commit 977ff27

Please sign in to comment.