User-Agent fix

include client version in user-agent
This commit is contained in:
John Economou 2023-03-20 13:43:25 +02:00
parent 40aadf77f7
commit b30fb1d9c7
5 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.service
import com.vitorpamplona.amethyst.BuildConfig
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -43,7 +44,7 @@ class Nip05Verifier {
withContext(Dispatchers.IO) {
try {
val request = Request.Builder()
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url(url)
.build()

View File

@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.service.lnurl
import com.vitorpamplona.amethyst.BuildConfig
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -52,7 +53,7 @@ class LightningAddressResolver {
withContext(Dispatchers.IO) {
val request: Request = Request.Builder()
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url(url)
.build()
@ -95,7 +96,7 @@ class LightningAddressResolver {
}
val request: Request = Request.Builder()
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url(url)
.build()

View File

@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.service.relays
import com.vitorpamplona.amethyst.BuildConfig
import android.util.Log
import com.google.gson.JsonElement
import com.vitorpamplona.amethyst.service.model.Event
@ -56,7 +57,7 @@ class Relay(
try {
val request = Request.Builder()
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url(url.trim())
.build()
val listener = object : WebSocketListener() {

View File

@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.ui.actions
import com.vitorpamplona.amethyst.BuildConfig
import android.content.ContentResolver
import android.content.ContentValues
import android.content.Context
@ -30,7 +31,7 @@ object ImageSaver {
val client = OkHttpClient.Builder().build()
val request = Request.Builder()
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.get()
.url(url)
.build()
@ -137,5 +138,5 @@ object ImageSaver {
MediaScannerConnection.scanFile(context, arrayOf(outputFile.toString()), null, null)
}
private const val PICTURES_SUBDIRECTORY = "Amethyst"
private const val PICTURES_SUBDIRECTORY = "Amethyst " + BuildConfig.VERSION_NAME
}

View File

@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.ui.actions
import com.vitorpamplona.amethyst.BuildConfig
import android.content.ContentResolver
import android.net.Uri
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@ -44,7 +45,7 @@ object ImageUploader {
val request: Request = Request.Builder()
.header("Authorization", "Client-ID e6aea87296f3f96")
.header("User-Agent", "Amethyst")
.header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url("https://api.imgur.com/3/image")
.post(requestBody)
.build()