Skip to content

Commit 6d0d9fe

Browse files
committed
fix: hide connectivity HTML quota if not supported
This also solves the problem with the fact that it's not clear from the resulting HTML that this error message is referring to quota and not something else. See #8130.
1 parent a017663 commit 6d0d9fe

4 files changed

Lines changed: 24 additions & 19 deletions

File tree

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7057,11 +7057,6 @@ void dc_event_unref(dc_event_t* event);
70577057
/// `%1$s` will be replaced by a possibly more detailed, typically english, error description.
70587058
#define DC_STR_ERROR 112
70597059

7060-
/// "Not supported by your provider."
7061-
///
7062-
/// Used in the connectivity view.
7063-
#define DC_STR_NOT_SUPPORTED_BY_PROVIDER 113
7064-
70657060
/// "Messages"
70667061
///
70677062
/// Used as a subtitle in quota context; can be plural always.

src/quota.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,39 @@
33
use std::collections::BTreeMap;
44
use std::time::Duration;
55

6-
use anyhow::{Context as _, Result, anyhow};
6+
use anyhow::{Context as _, Result};
77
use async_imap::types::{Quota, QuotaResource};
88

9+
use crate::EventType;
910
use crate::context::Context;
1011
use crate::imap::session::Session as ImapSession;
1112
use crate::tools::{self, time_elapsed};
12-
use crate::{EventType, stock_str};
1313

1414
/// quota icon in connectivity is "yellow".
1515
pub const QUOTA_WARN_THRESHOLD_PERCENTAGE: u64 = 80;
1616

1717
/// quota icon in connectivity is "red".
1818
pub const QUOTA_ERROR_THRESHOLD_PERCENTAGE: u64 = 95;
1919

20+
/// [QuotaInfo] error.
21+
#[derive(Debug, thiserror::Error)]
22+
pub enum Error {
23+
/// Quota info not supported by the provider
24+
#[error("Quota info not supported by the provider")]
25+
NotSupportedByProvider,
26+
27+
/// Any other error: network, parsing, etc.
28+
#[error("{0:#}")]
29+
Other(#[from] anyhow::Error),
30+
}
31+
2032
/// Server quota information with an update timestamp.
2133
#[derive(Debug)]
2234
pub struct QuotaInfo {
2335
/// Recently loaded quota information.
2436
/// set to `Err()` if the provider does not support quota or on other errors,
2537
/// set to `Ok()` for valid quota information.
26-
pub(crate) recent: Result<BTreeMap<String, Vec<QuotaResource>>>,
38+
pub(crate) recent: Result<BTreeMap<String, Vec<QuotaResource>>, Error>,
2739

2840
/// When the structure was modified.
2941
pub(crate) modified: tools::Time,
@@ -76,9 +88,11 @@ impl Context {
7688
info!(self, "Transport {transport_id}: Updating quota.");
7789

7890
let quota = if session.can_check_quota() {
79-
get_unique_quota_roots_and_usage(session, folder).await
91+
get_unique_quota_roots_and_usage(session, folder)
92+
.await
93+
.map_err(Error::Other)
8094
} else {
81-
Err(anyhow!(stock_str::not_supported_by_provider(self)))
95+
Err(Error::NotSupportedByProvider)
8296
};
8397

8498
self.quota.write().await.insert(

src/scheduler/connectivity.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ impl Context {
418418
};
419419
match &quota.recent {
420420
Err(e) => {
421-
ret += &escaper::encode_minimal(&e.to_string());
421+
// If not supported by the provider,
422+
// just skip the "quota" section.
423+
if !matches!(e, crate::quota::Error::NotSupportedByProvider) {
424+
ret += &escaper::encode_minimal(&e.to_string());
425+
}
422426
}
423427
Ok(quota) => {
424428
if quota.is_empty() {

src/stock_str.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ pub enum StockMessage {
189189
#[strum(props(fallback = "Error: %1$s"))]
190190
Error = 112,
191191

192-
#[strum(props(fallback = "Not supported by your provider."))]
193-
NotSupportedByProvider = 113,
194-
195192
#[strum(props(fallback = "Messages"))]
196193
Messages = 114,
197194

@@ -1137,11 +1134,6 @@ pub(crate) fn error(context: &Context, error: &str) -> String {
11371134
translated(context, StockMessage::Error).replace1(error)
11381135
}
11391136

1140-
/// Stock string: `Not supported by your provider.`.
1141-
pub(crate) fn not_supported_by_provider(context: &Context) -> String {
1142-
translated(context, StockMessage::NotSupportedByProvider)
1143-
}
1144-
11451137
/// Stock string: `Messages`.
11461138
/// Used as a subtitle in quota context; can be plural always.
11471139
pub(crate) fn messages(context: &Context) -> String {

0 commit comments

Comments
 (0)