public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [RFC PATCH pmg-api 1/1] api: quarantine: allow disabling images for content
Date: Tue, 13 Feb 2024 12:30:49 +0100	[thread overview]
Message-ID: <20240213113050.2349660-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240213113050.2349660-1-d.csapak@proxmox.com>

So that a client can control if images should be stripped from the
quarantine content, even if the server has 'viewimages' configured to on
in pmg.conf.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PMG/API2/Quarantine.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index a100e11..17f1405 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -867,6 +867,13 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 0,
 	    },
+	    'view-images' => {
+		description => "Controls if images are shown. Has no effect if 'viewimages'"
+		    ." is turned off in /etc/pmg/pmg.conf.",
+		type => 'boolean',
+		optional => 1,
+		default => 1,
+	    },
 	},
     },
     returns => {
@@ -944,6 +951,10 @@ __PACKAGE__->register_method ({
 
 	    my $cfg = PMG::Config->new();
 	    my $viewimages = $cfg->get('spamquar', 'viewimages');
+
+	    # only overwrite with the parameter when it's more strict than the config
+	    $viewimages = 0 if !($param->{'view-images'} // 1);
+
 	    my $allowhref = $cfg->get('spamquar', 'allowhrefs');
 
 	    $res->{content} = PMG::HTMLMail::email_to_html($path, $raw, $viewimages, $allowhref) // 'unable to parse mail';
-- 
2.30.2





  reply	other threads:[~2024-02-13 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 11:30 [pmg-devel] [RFC PATCH pmg-api/gui] add 'view images' checkbox to quarantine view Dominik Csapak
2024-02-13 11:30 ` Dominik Csapak [this message]
2024-02-21 14:12   ` [pmg-devel] [RFC PATCH pmg-api 1/1] api: quarantine: allow disabling images for content Mira Limbeck
2024-02-13 11:30 ` [pmg-devel] [RFC PATCH pmg-gui 1/1] quarantine content: add checkbox for controlling image loading Dominik Csapak
2024-02-21 14:17   ` Mira Limbeck
2024-02-21 18:51 ` [pmg-devel] [RFC PATCH pmg-api/gui] add 'view images' checkbox to quarantine view Thomas Lamprecht

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=20240213113050.2349660-2-d.csapak@proxmox.com \
    --to=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal