Don't show 406 error messages in AI.

This commit is contained in:
John Preston
2026-04-21 17:50:58 +07:00
parent c79f62d874
commit ae7ab838f4
3 changed files with 16 additions and 0 deletions

View File

@@ -212,6 +212,7 @@ api().request(MTPnamespace_MethodName(
```
- For single constructors, use `.data()` shortcut
- Include `.handleFloodErrors()` before `.send()` in rare cases where you want special case flood error handling
- Silently ignore HTTP 406 errors in UI: the server uses 406 to mean "show nothing to the user". Guard toasts with `MTP::IgnoreError(error)` or use `MTP::ShowErrorFallback(show, error)` (both in `mtproto/mtproto_response.h`) which shows `error.type()` as a toast unless the error should be ignored.
## UI Styling

View File

@@ -1203,6 +1203,10 @@ void ComposeAiContent::request() {
return;
}
weak->_requestId = 0;
if (MTP::IgnoreError(error)) {
weak->resetState(CardState::Waiting);
return;
}
weak->showError(error.type());
});
}

View File

@@ -57,6 +57,17 @@ inline bool IsDefaultHandledError(const Error &error) {
return IsTemporaryError(error);
}
inline bool IgnoreError(const Error &error) {
return error.code() == 406;
}
template <typename ShowPtr>
void ShowErrorFallback(const ShowPtr &show, const Error &error) {
if (!IgnoreError(error)) {
show->showToast(error.type());
}
}
struct Response {
mtpBuffer reply;
mtpMsgId outerMsgId = 0;