Unverified Commit fab68e52 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge pull request #1413 from RocketChat/new/set-user-agent

[NEW] Set user agent
parents 0cdd58ee d8a4fc25
package chat.rocket.android.server.infraestructure package chat.rocket.android.server.infraestructure
import android.os.Build
import chat.rocket.android.BuildConfig
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.common.util.PlatformLogger import chat.rocket.common.util.PlatformLogger
import chat.rocket.core.RocketChatClient import chat.rocket.core.RocketChatClient
import chat.rocket.android.server.domain.TokenRepository
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class RocketChatClientFactory @Inject constructor(private val okHttpClient: OkHttpClient, class RocketChatClientFactory @Inject constructor(
private val repository: TokenRepository, private val okHttpClient: OkHttpClient,
private val logger: PlatformLogger) { private val repository: TokenRepository,
private val logger: PlatformLogger
) {
private val cache = HashMap<String, RocketChatClient>() private val cache = HashMap<String, RocketChatClient>()
fun create(url: String): RocketChatClient { fun create(url: String): RocketChatClient {
...@@ -23,6 +27,7 @@ class RocketChatClientFactory @Inject constructor(private val okHttpClient: OkHt ...@@ -23,6 +27,7 @@ class RocketChatClientFactory @Inject constructor(private val okHttpClient: OkHt
val client = RocketChatClient.create { val client = RocketChatClient.create {
httpClient = okHttpClient httpClient = okHttpClient
restUrl = url restUrl = url
userAgent = "RC Mobile; Android ${Build.VERSION.RELEASE}; v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
tokenRepository = repository tokenRepository = repository
platformLogger = logger platformLogger = logger
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment