mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-24 16:51:07 +01:00
Moar cleanup
This commit is contained in:
parent
2df9b43abc
commit
5afdc81ce0
@ -53,22 +53,24 @@ fun Throwable.isInvalidUIAAuth(): Boolean {
|
||||
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
||||
*/
|
||||
fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
|
||||
return if (this is Failure.OtherServerError && this.httpCode == 401) {
|
||||
return if (this is Failure.OtherServerError && httpCode == 401) {
|
||||
tryOrNull {
|
||||
MoshiProvider.providesMoshi()
|
||||
.adapter(RegistrationFlowResponse::class.java)
|
||||
.fromJson(this.errorBody)
|
||||
.fromJson(errorBody)
|
||||
}
|
||||
} else if (this is Failure.ServerError && this.httpCode == 401 && this.error.code == MatrixError.M_FORBIDDEN) {
|
||||
} else if (this is Failure.ServerError && httpCode == 401 && error.code == MatrixError.M_FORBIDDEN) {
|
||||
// This happens when the submission for this stage was bad (like bad password)
|
||||
if (this.error.session != null && this.error.flows != null) {
|
||||
if (error.session != null && error.flows != null) {
|
||||
RegistrationFlowResponse(
|
||||
flows = this.error.flows,
|
||||
session = this.error.session,
|
||||
completedStages = this.error.completedStages,
|
||||
params = this.error.params
|
||||
flows = error.flows,
|
||||
session = error.session,
|
||||
completedStages = error.completedStages,
|
||||
params = error.params
|
||||
)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user