Skip to content

Commit

Permalink
Fix #221
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Heckel committed Apr 23, 2022
1 parent d13c5f9 commit 4ad6846
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/src/main/java/io/heckel/ntfy/msg/UserActionWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ class UserActionWorker(private val context: Context, params: WorkerParameters) :
save(action.copy(progress = ACTION_PROGRESS_ONGOING, error = null))

val url = action.url ?: return
val method = action.method ?: "POST" // (not GET, because POST as a default makes more sense!)
val body = action.body ?: ""
val method = action.method ?: DEFAULT_HTTP_ACTION_METHOD
val defaultBody = if (listOf("GET", "HEAD").contains(method)) null else ""
val body = action.body ?: defaultBody
val builder = Request.Builder()
.url(url)
.method(method, body.toRequestBody())
.method(method, body?.toRequestBody())
.addHeader("User-Agent", ApiService.USER_AGENT)
action.headers?.forEach { (key, value) ->
builder.addHeader(key, value)
Expand Down Expand Up @@ -134,6 +135,7 @@ class UserActionWorker(private val context: Context, params: WorkerParameters) :
const val INPUT_DATA_NOTIFICATION_ID = "notificationId"
const val INPUT_DATA_ACTION_ID = "actionId"

private const val DEFAULT_HTTP_ACTION_METHOD = "POST" // Cannot be changed without changing the contract
private const val TAG = "NtfyUserActWrk"
}
}
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelog/26.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bugs:
* Validate URLs when changing default server and server in user management (#193, thanks to @StoyanDimitrov for reporting)
* Error in sending test notification in different languages (#209, thanks to @StoyanDimitrov for reporting)
* "[x] Instant delivery in doze mode" checkbox does not work properly (#211)
* Disallow "http" GET/HEAD actions with body (#221, thanks to @cmeis for reporting)

Additional translations:
* Japanese (thanks to @shak)
Expand Down

0 comments on commit 4ad6846

Please sign in to comment.