Fix push gateway with some push provider (Sunup/autopush) (#5741)

* Add more HTTP response code returning NoMatrixGateway

Fix Push notifications with Mozilla's autopush that returns 406

* Update gateway resolver tests to match new known errors
This commit is contained in:
S1m 2025-11-17 12:34:35 +00:00 committed by GitHub
parent 6bdb4d1ad4
commit 3cbdc97cdd
2 changed files with 44 additions and 3 deletions

View file

@ -64,8 +64,9 @@ class DefaultUnifiedPushGatewayResolver(
UnifiedPushGatewayResolverResult.NoMatrixGateway
}
} catch (throwable: Throwable) {
if ((throwable as? HttpException)?.code() == HttpURLConnection.HTTP_NOT_FOUND) {
Timber.tag(loggerTag.value).i("Checking for UnifiedPush endpoint yielded 404, using fallback")
val code = (throwable as? HttpException)?.code()
if (code in NoMatrixGatewayResp) {
Timber.tag(loggerTag.value).i("Checking for UnifiedPush endpoint yielded $code, using fallback")
UnifiedPushGatewayResolverResult.NoMatrixGateway
} else {
Timber.tag(loggerTag.value).e(throwable, "Error checking for UnifiedPush endpoint")
@ -75,4 +76,14 @@ class DefaultUnifiedPushGatewayResolver(
}
}
}
companion object {
private val NoMatrixGatewayResp = listOf<Int>(
HttpURLConnection.HTTP_UNAUTHORIZED,
HttpURLConnection.HTTP_FORBIDDEN,
HttpURLConnection.HTTP_NOT_FOUND,
HttpURLConnection.HTTP_BAD_METHOD,
HttpURLConnection.HTTP_NOT_ACCEPTABLE
)
}
}