mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-20 08:03:45 +08:00
Don't show 406 error messages in AI.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -1203,6 +1203,10 @@ void ComposeAiContent::request() {
|
||||
return;
|
||||
}
|
||||
weak->_requestId = 0;
|
||||
if (MTP::IgnoreError(error)) {
|
||||
weak->resetState(CardState::Waiting);
|
||||
return;
|
||||
}
|
||||
weak->showError(error.type());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user