mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-02-01 11:26:48 +01:00
古いサーバでサーバ情報を読めなかった問題の修正
This commit is contained in:
parent
7200c86669
commit
54a7a4df36
@ -400,24 +400,27 @@ class TootInstance(parser: TootParser, src: JsonObject) {
|
|||||||
private suspend fun TootApiClient.getInstanceInformationMastodon(
|
private suspend fun TootApiClient.getInstanceInformationMastodon(
|
||||||
forceAccessToken: String? = null,
|
forceAccessToken: String? = null,
|
||||||
): TootApiResult? {
|
): TootApiResult? {
|
||||||
val result = TootApiResult.makeWithCaption(apiHost)
|
var lastError: TootApiResult? = null
|
||||||
if (result.error != null) return result
|
|
||||||
for (path in arrayOf("/api/v2/instance", "/api/v1/instance")) {
|
for (path in arrayOf("/api/v2/instance", "/api/v1/instance")) {
|
||||||
|
val result = TootApiResult.makeWithCaption(apiHost)
|
||||||
|
if (result.error != null) return result
|
||||||
val url = "https://${apiHost?.ascii}$path"
|
val url = "https://${apiHost?.ascii}$path"
|
||||||
if (!sendRequest(result) {
|
if (sendRequest(result) {
|
||||||
val builder = Request.Builder().url(url)
|
val builder = Request.Builder().url(url)
|
||||||
(forceAccessToken ?: account?.bearerAccessToken)?.notEmpty()?.let {
|
(forceAccessToken ?: account?.bearerAccessToken)?.notEmpty()?.let {
|
||||||
builder.header("Authorization", "Bearer $it")
|
builder.header("Authorization", "Bearer $it")
|
||||||
}
|
}
|
||||||
builder.build()
|
builder.build()
|
||||||
}) continue
|
}) {
|
||||||
parseJson(result) ?: return null // cancelled.
|
parseJson(result) ?: return null // cancelled.
|
||||||
result.jsonObject?.let { json ->
|
result.jsonObject?.let { json ->
|
||||||
json.jsonObject("configuration")?.put("!instanceApiUrl", url)
|
json.jsonObject("configuration")?.put("!instanceApiUrl", url)
|
||||||
return result
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
lastError = result
|
||||||
}
|
}
|
||||||
return result
|
return lastError!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun TootApiClient.getMisskeyEndpoints(
|
private suspend fun TootApiClient.getMisskeyEndpoints(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user