Merge pull request #296 from hsoc/useragent-ver

User-Agent fix
This commit is contained in:
Vitor Pamplona
2023-03-20 08:36:13 -04:00
committed by GitHub
5 changed files with 12 additions and 7 deletions

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.ui.actions package com.vitorpamplona.amethyst.ui.actions
import com.vitorpamplona.amethyst.BuildConfig
import android.content.ContentResolver import android.content.ContentResolver
import android.content.ContentValues import android.content.ContentValues
import android.content.Context import android.content.Context
@@ -30,7 +31,7 @@ object ImageSaver {
val client = OkHttpClient.Builder().build() val client = OkHttpClient.Builder().build()
val request = Request.Builder() val request = Request.Builder()
.header("User-Agent", "Amethyst") .header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.get() .get()
.url(url) .url(url)
.build() .build()
@@ -137,5 +138,5 @@ object ImageSaver {
MediaScannerConnection.scanFile(context, arrayOf(outputFile.toString()), null, null) 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 package com.vitorpamplona.amethyst.ui.actions
import com.vitorpamplona.amethyst.BuildConfig
import android.content.ContentResolver import android.content.ContentResolver
import android.net.Uri import android.net.Uri
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@@ -44,7 +45,7 @@ object ImageUploader {
val request: Request = Request.Builder() val request: Request = Request.Builder()
.header("Authorization", "Client-ID e6aea87296f3f96") .header("Authorization", "Client-ID e6aea87296f3f96")
.header("User-Agent", "Amethyst") .header("User-Agent", "Amethyst " + BuildConfig.VERSION_NAME)
.url("https://api.imgur.com/3/image") .url("https://api.imgur.com/3/image")
.post(requestBody) .post(requestBody)
.build() .build()