From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links
Date: Tue, 28 Oct 2025 17:36:17 +0100 [thread overview]
Message-ID: <20251028163628.79739-3-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20251028163628.79739-1-s.ivanov@proxmox.com>
Our html verbose spamreports have included links for each possible
action for each mail (delete, deliver, blocklist, welcomelist) in the
action GET parameter. Currently the yew-based mobile view does not
handle those actions.
This patch adds the functionality by issueing a POST request in the
view function if the a cselect (id) and action parameter are present.
I tried adding the same call to the update function, but it seems the
update function does not get the query-string after a login, or was not
called in my tests.
Big thanks to Dominik for walking me through our yew framework and
providing other valuable suggestions!
Reported in our community forum:
https://forum.proxmox.com/threads/.174685/
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/main.rs | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
index 8cd8a6b..366cdc7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,7 @@
mod spam_list;
+use std::str::FromStr;
+
pub use spam_list::SpamList;
mod page_mail_view;
@@ -14,7 +16,7 @@ pub use page_not_found::PageNotFound;
mod page_login;
pub use page_login::PageLogin;
-use anyhow::Error;
+use anyhow::{format_err, Error};
use gloo_utils::{document, format::JsValueSerdeExt};
use serde::Deserialize;
use serde_json::{json, Value};
@@ -114,6 +116,15 @@ impl Component for PmgQuarantineApp {
let logged_in = self.login_info.is_some();
MaterialApp::new(move |path: &str| {
if logged_in {
+ let document = document();
+ let location = document.location().unwrap();
+ let search = location.search().unwrap();
+ let param = web_sys::UrlSearchParams::new_with_str(&search).unwrap();
+ if let (Some(id), Some(action)) = (param.get("cselect"), param.get("action")) {
+ wasm_bindgen_futures::spawn_local(async move {
+ _ = mail_action(&id, MailAction::from_str(&action).unwrap()).await
+ });
+ }
switch(path)
} else {
vec![PageLogin::new().on_login(link.callback(Msg::Login)).into()]
@@ -187,6 +198,21 @@ impl std::fmt::Display for MailAction {
}
}
+impl std::str::FromStr for MailAction {
+ type Err = anyhow::Error;
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "deliver" => Ok(MailAction::Deliver),
+ "delete" => Ok(MailAction::Delete),
+ "welcomelist" => Ok(MailAction::Welcomelist),
+ "whitelist" => Ok(MailAction::Welcomelist),
+ "blocklist" => Ok(MailAction::Blocklist),
+ "blacklist" => Ok(MailAction::Blocklist),
+ _ => Err(format_err!("unknown quarantine action")),
+ }
+ }
+}
+
pub(crate) async fn mail_action(id: &str, action: MailAction) -> Result<Value, Error> {
let param = json!({
"action": action.to_string(),
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next prev parent reply other threads:[~2025-10-28 16:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 16:36 [pmg-devel] [RFC pmg-yew-quarantine-gui 0/2] fix direct actions from " Stoiko Ivanov
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically Stoiko Ivanov
2025-10-29 8:59 ` Dominik Csapak
2025-10-29 17:27 ` [pmg-devel] applied: " Thomas Lamprecht
2025-10-28 16:36 ` Stoiko Ivanov [this message]
2025-10-29 9:09 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251028163628.79739-3-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.