Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/cordiale-ui/lang/de/LC_MESSAGES/cordiale-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@ msgctxt "AppWindow"
msgid "Admin actions need an administrator signed in with a full session. A client token can't do them."
msgstr "Admin-Aktionen erfordern einen Administrator mit vollständiger Sitzung. Ein Client-Token kann sie nicht ausführen."

msgctxt "AppWindow"
msgid "Couldn't delete that visitor ({}). A visitor with a lot of history can time out on the server; try again, or ask the server admin."
msgstr "Der Besucher konnte nicht gelöscht werden ({}). Ein Besucher mit viel Verlauf kann auf dem Server in ein Timeout laufen: Versuche es erneut oder frage den Serveradministrator."

msgctxt "AppWindow"
msgid "That network still has accounts bound to it. Unbind them on the Credentials tab first."
msgstr "An dieses Netzwerk sind noch Konten gebunden. Löse sie zuerst im Tab „Zugangsdaten“."
Expand Down
4 changes: 4 additions & 0 deletions crates/cordiale-ui/lang/es/LC_MESSAGES/cordiale-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@ msgctxt "AppWindow"
msgid "Admin actions need an administrator signed in with a full session. A client token can't do them."
msgstr "Las acciones de administración requieren un administrador con una sesión completa. Un token de cliente no puede realizarlas."

msgctxt "AppWindow"
msgid "Couldn't delete that visitor ({}). A visitor with a lot of history can time out on the server; try again, or ask the server admin."
msgstr "No se pudo eliminar ese visitante ({}). Un visitante con mucho historial puede agotar el tiempo en el servidor: inténtalo de nuevo o consulta al administrador del servidor."

msgctxt "AppWindow"
msgid "That network still has accounts bound to it. Unbind them on the Credentials tab first."
msgstr "Esa red todavía tiene cuentas vinculadas. Desvincúlalas primero en la pestaña Credenciales."
Expand Down
4 changes: 4 additions & 0 deletions crates/cordiale-ui/lang/fr/LC_MESSAGES/cordiale-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@ msgctxt "AppWindow"
msgid "Admin actions need an administrator signed in with a full session. A client token can't do them."
msgstr "Les actions d'administration nécessitent un administrateur connecté avec une session complète. Un jeton client ne peut pas les effectuer."

msgctxt "AppWindow"
msgid "Couldn't delete that visitor ({}). A visitor with a lot of history can time out on the server; try again, or ask the server admin."
msgstr "Impossible de supprimer ce visiteur ({}). Un visiteur avec beaucoup d'historique peut dépasser le délai côté serveur : réessaie ou contacte l'administrateur du serveur."

msgctxt "AppWindow"
msgid "That network still has accounts bound to it. Unbind them on the Credentials tab first."
msgstr "Des comptes sont encore associés à ce réseau. Dissocie-les d'abord dans l'onglet Identifiants."
Expand Down
4 changes: 4 additions & 0 deletions crates/cordiale-ui/lang/it/LC_MESSAGES/cordiale-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@ msgctxt "AppWindow"
msgid "Admin actions need an administrator signed in with a full session. A client token can't do them."
msgstr "Le azioni di amministrazione richiedono un amministratore con una sessione completa. Un token client non può eseguirle."

msgctxt "AppWindow"
msgid "Couldn't delete that visitor ({}). A visitor with a lot of history can time out on the server; try again, or ask the server admin."
msgstr "Impossibile eliminare quel visitor ({}). Un visitor con molta cronologia può andare in timeout sul server: riprova o contatta l'amministratore del server."

msgctxt "AppWindow"
msgid "That network still has accounts bound to it. Unbind them on the Credentials tab first."
msgstr "A quella rete sono ancora collegati degli account. Scollegali prima dalla scheda Credenziali."
Expand Down
25 changes: 21 additions & 4 deletions crates/cordiale-ui/src/admin_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ pub(crate) fn admin_failure_kind(status: Option<u16>, network_delete: bool) -> &
}
}

/// The status line for a failed visitor delete. A server error or a dropped
/// connection is what a slow bulk delete looks like (Grappa's write pool can
/// time out on a visitor with a lot of scrollback), so it gets its own text
/// with a retry hint; anything else follows `admin_failure_kind`.
pub(crate) fn admin_visitor_delete_failure_kind(status: Option<u16>) -> &'static str {
match status {
None => "admin-visitor-delete-failed",
Some(code) if code >= 500 => "admin-visitor-delete-failed",
other => admin_failure_kind(other, false),
}
}

/// One `subject_search` row: `(type, id, network, nick)`, `network` empty
/// for an account.
pub(crate) fn admin_subject_row(row: &Value) -> Option<(String, String, String, String)> {
Expand Down Expand Up @@ -104,6 +116,9 @@ pub(crate) async fn handle_admin_write(
AdminWrite::DeleteNetwork(network_id) => {
(client.delete_admin_network(token, network_id).await, "")
}
AdminWrite::DeleteVisitor(visitor_id) => {
(client.delete_admin_visitor(token, visitor_id).await, "")
}
AdminWrite::AddServer {
network_id,
host,
Expand Down Expand Up @@ -267,10 +282,12 @@ pub(crate) async fn handle_admin_write(
.map(|status| status.as_u16().to_string())
.unwrap_or_else(|| "network error".to_string());
persistence::log_line(&format!("admin write failed: {status}"));
let kind = admin_failure_kind(
err.status().map(|status| status.as_u16()),
matches!(write, AdminWrite::DeleteNetwork(_)),
);
let code = err.status().map(|status| status.as_u16());
let kind = if matches!(write, AdminWrite::DeleteVisitor(_)) {
admin_visitor_delete_failure_kind(code)
} else {
admin_failure_kind(code, matches!(write, AdminWrite::DeleteNetwork(_)))
};
let _ = ui.upgrade_in_event_loop(move |ui| {
ui.set_status_command_hint(status.into());
ui.set_status_kind(kind.into());
Expand Down
7 changes: 3 additions & 4 deletions crates/cordiale-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1969,10 +1969,8 @@ async fn run_worker(
handle_admin_refresh(&state, &ui).await;
}
Some(WorkerCommand::AdminVisitorDelete(visitor_id)) => {
if let (Some(client), Some(token)) = (&state.conn.client, &state.conn.token) {
let _ = client.delete_admin_visitor(token, &visitor_id).await;
}
handle_admin_refresh(&state, &ui).await;
handle_admin_write(&state, &ui, AdminWrite::DeleteVisitor(visitor_id))
.await;
}
Some(WorkerCommand::AdminNetworkResetCircuit(network_id)) => {
if let (Some(client), Some(token)) = (&state.conn.client, &state.conn.token) {
Expand Down Expand Up @@ -5708,6 +5706,7 @@ enum AdminWrite {
password: String,
},
CreateNetwork(String),
DeleteVisitor(String),
UpdateNetwork {
slug: String,
settings: Value,
Expand Down
19 changes: 19 additions & 0 deletions crates/cordiale-ui/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4657,6 +4657,25 @@ fn a_refused_admin_write_is_told_apart() {
assert_eq!(admin_failure_kind(None, true), "admin-action-failed");
}

#[test]
fn a_failed_visitor_delete_says_to_retry() {
// Timeouts and dropped connections look like a slow bulk delete.
for status in [Some(500), Some(503), None] {
assert_eq!(
admin_visitor_delete_failure_kind(status),
"admin-visitor-delete-failed"
);
}
assert_eq!(
admin_visitor_delete_failure_kind(Some(403)),
"admin-forbidden"
);
assert_eq!(
admin_visitor_delete_failure_kind(Some(404)),
"admin-action-failed"
);
}

#[test]
fn network_delete_needs_a_count_for_that_network() {
let mut state = WorkerState::new();
Expand Down
2 changes: 2 additions & 0 deletions crates/cordiale-ui/ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,8 @@ export component AppWindow inherits Window {
return @tr("The server refused that admin action ({}).", status-command-hint);
} else if status-kind == "admin-forbidden" {
return @tr("Admin actions need an administrator signed in with a full session. A client token can't do them.");
} else if status-kind == "admin-visitor-delete-failed" {
return @tr("Couldn't delete that visitor ({}). A visitor with a lot of history can time out on the server; try again, or ask the server admin.", status-command-hint);
} else if status-kind == "admin-network-in-use" {
return @tr("That network still has accounts bound to it. Unbind them on the Credentials tab first.");
} else if status-kind == "admin-credential-stopped" {
Expand Down
Loading