Этап 1: единый OkHttpClient ч.2 — 401 централизован через interceptor
- UnauthorizedInterceptor (401→UnauthorizedException) в NetworkFactory, флаг throwOnUnauthorized (по умолчанию true). - Удалены 75 ручных проверок if(code==401) throw в 16 репозиториях. - AuthVerifier (login-верификация) исключён: throwOnUnauthorized=false — 401 = 'неверный пароль' со своим сообщением, не session-expired. - Побочно: 401 теперь ловится единообразно ВЕЗДЕ (включая пути, что раньше забывали проверку). - +3 MockWebServer-теста (401 бросает; 200/403 проходят) — всего 18 тестов. Проверено: 18 тестов зелёные + assembleRelease BUILD SUCCESSFUL, APK 53 МБ.
This commit is contained in:
-4
@@ -46,7 +46,6 @@ class CalendarApiClient {
|
||||
.applyOcsJson()
|
||||
.build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (response.code == 401) throw UnauthorizedException()
|
||||
val json = parseJsonObject(response.body?.string().orEmpty(), "autocomplete attendee")
|
||||
val data = json.optJSONArray("data") ?: json.optJSONObject("ocs")?.optJSONArray("data") ?: return emptyList()
|
||||
return buildList {
|
||||
@@ -77,7 +76,6 @@ class CalendarApiClient {
|
||||
.applyOcsJson()
|
||||
.build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (response.code == 401) throw UnauthorizedException()
|
||||
val json = parseJsonObject(response.body?.string().orEmpty(), "autocomplete location")
|
||||
val data = json.optJSONArray("data") ?: return emptyList()
|
||||
return buildList {
|
||||
@@ -104,7 +102,6 @@ class CalendarApiClient {
|
||||
.applyOcsJson()
|
||||
.build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (response.code == 401) throw UnauthorizedException()
|
||||
if (!response.isSuccessful) error("Calendar config failed HTTP ${response.code}")
|
||||
}
|
||||
}
|
||||
@@ -124,7 +121,6 @@ class CalendarApiClient {
|
||||
.applyOcsJson()
|
||||
.build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (response.code == 401) throw UnauthorizedException()
|
||||
val json = parseJsonObject(response.body?.string().orEmpty(), "create talk room")
|
||||
val meta = json.ocsMeta()
|
||||
if (!isOcsSuccess(meta)) error("Не удалось создать комнату Talk")
|
||||
|
||||
Reference in New Issue
Block a user