From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EB9961FF179 for ; Wed, 29 Oct 2025 10:09:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 94DC23FA8; Wed, 29 Oct 2025 10:09:58 +0100 (CET) Message-ID: <93c3abb6-c6ae-4a40-b0e9-79249f94b9c8@proxmox.com> Date: Wed, 29 Oct 2025 10:09:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Stoiko Ivanov , pmg-devel@lists.proxmox.com References: <20251028163628.79739-1-s.ivanov@proxmox.com> <20251028163628.79739-3-s.ivanov@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20251028163628.79739-3-s.ivanov@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761728950878 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" This is not correct I'm afraid. It works, but just "by accident" Usually doing such things in the 'view' method is not good, since that can trigger any amount of times, depending on what happens to the component. it currently triggers only once, because when we login, we replace the url via the 'location' which causes a refresh of the page, but seemingly only after all outstanding javascript is finished running with that refresh, we lose all state Also we don't have any feedback here that the action was done. I'll have an idea how to solve this, but it's a bit more involved than this. I'd send a patch later if you don't mind On 10/28/25 5:36 PM, Stoiko Ivanov wrote: > 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 > --- > 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 { > + 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 { > let param = json!({ > "action": action.to_string(), _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel