From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4FC478E5B8 for ; Fri, 11 Nov 2022 18:59:58 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 36258680D for ; Fri, 11 Nov 2022 18:59:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 11 Nov 2022 18:59:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AB32B43B03 for ; Fri, 11 Nov 2022 18:59:26 +0100 (CET) Message-ID: <40412296-fb22-4884-be30-8a8d4a25cc88@proxmox.com> Date: Fri, 11 Nov 2022 18:59:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Thunderbird/107.0 Content-Language: en-GB To: Dominik Csapak , pmg-devel@lists.proxmox.com References: <20221107143620.1898890-1-d.csapak@proxmox.com> <20221107143620.1898890-4-d.csapak@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20221107143620.1898890-4-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.033 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] applied: [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default 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: , X-List-Received-Date: Fri, 11 Nov 2022 17:59:58 -0000 s/AttachmentGrid/attachment grid/ in the subject gives a slightly better searchable tag. Am 07/11/2022 um 15:36 schrieb Dominik Csapak: > normally, attachments are given the 'content-disposition: attachment' > mime attribute, so we use that to filter the attachements > > but since we're dealing with spam & virus mails here, and that field > is client controlled, give the user a way to toggle the remaining parts > of the mail too. > > added the checkbox in the header part, but that made it necessary to > manually implement the expand/collapse toggle (since the tools are on > the wrong side of the default toggle) > > Signed-off-by: Dominik Csapak > --- > js/AttachmentGrid.js | 61 ++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 50 insertions(+), 11 deletions(-) > > applied, thanks! I moved the checkbox into the tbar, as I don't think it is something often wanted/used, as while yes, the content-disposition is user controllable, most (all?) MUAs only show it if set so even spammers/attackers have it in their interest to set it if they actually want to make it useable/ downloadable. That then allows to turn back on the native titleCollapse, which I find a bit more ergonomic. Slight drawback is tohave 1.5 rows "wasted" due to the tbar, but one can still see 6 attachments just fine and IMO not really a concern (tbh. I'd just drop that checkbox if it really is deemed to use to much space in the tbar). > @@ -35,8 +71,15 @@ Ext.define('PMG.grid.AttachmentGrid', { > view.updateTitleStats(-1); > return; > } > - let totalSize = records.reduce((sum, { data }) => sum + data.size, 0); > - view.updateTitleStats(records.length, totalSize); > + let count = 0; > + let totalSize = records.reduce((sum, { data }) => { > + if (data['content-disposition'] === 'attachment') { > + count++; > + return sum + data.size; > + } > + return sum; > + }, 0); for such thing's it IMO simpler to use a .filter first, i.e., I reworked it to: let attachments = records.filter(({ data }) => data['content-disposition'] === 'attachment'); let totalSize = attachments.reduce((sum, { data }) => sum + data.size, 0); view.updateTitleStats(attachments.length, totalSize); > + view.updateTitleStats(count, totalSize); > }, > }, >