Adds a check for the main thread when pulling opengraph tags.

pull/771/head
Vitor Pamplona 2024-02-13 11:38:28 -05:00
rodzic d41eb4ce31
commit c9d59fd5ac
1 zmienionych plików z 2 dodań i 0 usunięć

Wyświetl plik

@ -21,6 +21,7 @@
package com.vitorpamplona.amethyst.service.previews
import com.vitorpamplona.amethyst.service.HttpClientManager
import com.vitorpamplona.amethyst.service.checkNotInMainThread
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.MediaType
@ -91,6 +92,7 @@ suspend fun getDocument(
withContext(Dispatchers.IO) {
val request: Request = Request.Builder().url(url).get().build()
HttpClientManager.getHttpClient().newCall(request).execute().use {
checkNotInMainThread()
if (it.isSuccessful) {
val mimeType =
it.headers.get("Content-Type")?.toMediaType()