mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
committed by
Greyson Parrelli
parent
9824cc2cbe
commit
8ba57a2733
@@ -58,18 +58,21 @@ class InstrumentationApplicationDependencyProvider(val application: Application,
|
||||
Get("/v1/websocket/?login=") {
|
||||
MockResponse().success().withWebSocketUpgrade(mockIdentifiedWebSocket)
|
||||
},
|
||||
Get("/v1/websocket", { !it.path.contains("login") }) {
|
||||
Get("/v1/websocket", {
|
||||
val path = it.path
|
||||
return@Get path == null || !path.contains("login")
|
||||
}) {
|
||||
MockResponse().success().withWebSocketUpgrade(object : WebSocketListener() {})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
webServer.setDispatcher(object : Dispatcher() {
|
||||
webServer.dispatcher = object : Dispatcher() {
|
||||
override fun dispatch(request: RecordedRequest): MockResponse {
|
||||
val handler = handlers.firstOrNull { it.requestPredicate(request) }
|
||||
return handler?.responseFactory?.invoke(request) ?: MockResponse().setResponseCode(500)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
serviceTrustStore = SignalServiceTrustStore(application)
|
||||
uncensoredConfiguration = SignalServiceConfiguration(
|
||||
|
||||
@@ -55,5 +55,5 @@ inline fun <reified T> RecordedRequest.parsedRequestBody(): T {
|
||||
}
|
||||
|
||||
private fun defaultRequestPredicate(verb: String, path: String, predicate: RequestPredicate = { true }): RequestPredicate = { request ->
|
||||
request.method == verb && request.path.startsWith("/$path") && predicate(request)
|
||||
request.method == verb && request.path?.startsWith("/$path") == true && predicate(request)
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
|
||||
val request = Request.Builder().url(BuildConfig.APK_UPDATE_MANIFEST_URL).build()
|
||||
|
||||
val rawUpdateDescriptor: String = client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful || response.body() == null) {
|
||||
if (!response.isSuccessful || response.body == null) {
|
||||
throw IOException("Failed to read update descriptor")
|
||||
}
|
||||
response.body()!!.string()
|
||||
response.body!!.string()
|
||||
}
|
||||
|
||||
val updateDescriptor: UpdateDescriptor = JsonUtils.fromJson(rawUpdateDescriptor, UpdateDescriptor::class.java)
|
||||
|
||||
@@ -400,7 +400,7 @@ class AttachmentDownloadJob private constructor(
|
||||
) {
|
||||
try {
|
||||
S3.getObject(attachment.fileName!!).use { response ->
|
||||
val body = response.body()
|
||||
val body = response.body
|
||||
if (body != null) {
|
||||
if (body.contentLength() > RemoteConfig.maxAttachmentReceiveSizeBytes) {
|
||||
throw MmsException("Attachment too large, failing download")
|
||||
|
||||
@@ -42,7 +42,7 @@ class FetchRemoteMegaphoneImageJob(parameters: Parameters, private val uuid: Str
|
||||
override fun onRun() {
|
||||
try {
|
||||
S3.getObject(imageUrl).use { response ->
|
||||
val body: ResponseBody? = response.body()
|
||||
val body: ResponseBody? = response.body
|
||||
if (body != null) {
|
||||
val uri = BlobProvider.getInstance()
|
||||
.forData(body.byteStream(), body.contentLength())
|
||||
|
||||
@@ -53,10 +53,10 @@ object S3 {
|
||||
fun getString(endpoint: String): String {
|
||||
getObject(endpoint).use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
throw NonSuccessfulResponseCodeException(response.code())
|
||||
throw NonSuccessfulResponseCodeException(response.code)
|
||||
}
|
||||
|
||||
return response.body()?.string()?.trim() ?: throw IOException()
|
||||
return response.body?.string()?.trim() ?: throw IOException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ object S3 {
|
||||
getObject(endpoint).use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
return ServiceResponse.forApplicationError(
|
||||
DefaultErrorMapper.getDefault().parseError(response.code()),
|
||||
response.code(),
|
||||
DefaultErrorMapper.getDefault().parseError(response.code),
|
||||
response.code,
|
||||
""
|
||||
)
|
||||
}
|
||||
|
||||
val source = response.body()?.source()
|
||||
val source = response.body?.source()
|
||||
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
|
||||
@@ -166,7 +166,7 @@ object S3 {
|
||||
}
|
||||
|
||||
getObject(objectPathOnNetwork).use { response ->
|
||||
val source = response.body()?.source()
|
||||
val source = response.body?.source()
|
||||
|
||||
val outputStream: OutputStream = if (doNotEncrypt) {
|
||||
FileOutputStream(objectFileOnDisk)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import org.thoughtcrime.securesms.stickers.StickerUrl
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
@@ -43,7 +43,7 @@ object LinkUtil {
|
||||
return false
|
||||
}
|
||||
|
||||
return HttpUrl.parse(linkUrl)?.scheme() == "https"
|
||||
return linkUrl.toHttpUrlOrNull()?.scheme == "https"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user