Pārlūkot izejas kodu

Address review feedback on mailto subject PR

- Hoist the subject's I18n._() call into a single const reused by
  both the confirmation-modal and direct-send paths, instead of an
  extra one-line function calling another function (per elrido).
- Regenerate the SRI hash for js/privatebin.js in lib/Configuration.php.
- Add a CHANGELOG.md entry under 2.1.0, referencing #928.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
vatsanbalaji-ossagent 1 dienu atpakaļ
vecāks
revīzija
1bf6888bb7
3 mainītis faili ar 7 papildinājumiem un 16 dzēšanām
  1. 1 0
      CHANGELOG.md
  2. 5 15
      js/privatebin.js
  3. 1 1
      lib/Configuration.php

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@
 ## 2.1.0 (not yet released)
 * ADDED: Added `shortenviachhoto` endpoint with an `chhoto` configuration section
 * ADDED: Translation for Chinese (Traditional)
+* ADDED: Subject line to the "Email" share button's mailto link (#928)
 * CHANGED: We removed jQuery in the Frontend and replaced it with vanilla JS.
 * CHANGED: Removed the unmaintained js-verify and replaced it with fast-check library.
 * CHANGED: Added a `jsconfig.json` in order to check the types of JavaScript.

+ 5 - 15
js/privatebin.js

@@ -4163,19 +4163,6 @@ window.PrivateBin = (function () {
             return emailBody;
         }
 
-        /**
-         * Template Email subject.
-         *
-         * Reuses the same translated string as the page's social media
-         * preview title, so no new translations are required.
-         *
-         * @name   TopNav.templateEmailSubject
-         * @private
-         */
-        function templateEmailSubject() {
-            return I18n._('Encrypted note on %s', document.title);
-        }
-
         /**
          * Trigger Email send.
          *
@@ -4210,6 +4197,9 @@ window.PrivateBin = (function () {
             );
             expirationDateRoundedToSecond.setUTCSeconds(0);
 
+            // reused as-is by both the confirmation-modal and direct-send paths below
+            const emailSubject = I18n._('Encrypted note on %s', document.title);
+
             const emailconfirmmodal = document.getElementById('emailconfirmmodal');
             if (expirationDate !== null) {
                 const emailconfirmTimezoneCurrent = emailconfirmmodal.querySelector('#emailconfirm-timezone-current');
@@ -4228,7 +4218,7 @@ window.PrivateBin = (function () {
                     if (bootstrap5EmailConfirmModal) {
                         bootstrap5EmailConfirmModal.hide();
                     }
-                    triggerEmailSend(templateEmailSubject(), emailBody);
+                    triggerEmailSend(emailSubject, emailBody);
                 }
 
                 emailconfirmmodal.addEventListener('shown.bs.modal', () => {
@@ -4246,7 +4236,7 @@ window.PrivateBin = (function () {
                     bootstrap5EmailConfirmModal.show();
                 }
             } else {
-                triggerEmailSend(templateEmailSubject(), templateEmailBody(null, isBurnafterreading));
+                triggerEmailSend(emailSubject, templateEmailBody(null, isBurnafterreading));
             }
         }
 

+ 1 - 1
lib/Configuration.php

@@ -124,7 +124,7 @@ class Configuration
             'js/kjua-0.10.0.js'      => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==',
             'js/legacy.js'           => 'sha512-pRofxsrf5UItjiP22Dcjh3FAcBjF/n7h8U9/W5xqJk17U0N2U1oajhXypq/omo9jhwS1iVGOhWrRepoPeFns+w==',
             'js/prettify.js'         => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
-            'js/privatebin.js'       => 'sha512-EDBvid7ZFsTiqmEbYUR2Bwo7ypn7GKf+JwW6VFvdE6qLQbzdKrAla+AKhONnt/Tve3zEPc9bXI+4hUHl5itdZw==',
+            'js/privatebin.js'       => 'sha512-DjYeZ4i5PIYZWOP/FuOE9rMPCF0x7UCuu2SPFuohQMYTQp1/Ysr1zWCo1KUPuozumvvxsxq+zVaAQ+07N29oog==',
             'js/purify-3.4.12.js'    => 'sha512-Akf6HnAJZm0sWWWI4gp2GYff0NDnHUB02XJE5S7Hdq/Z5xtMjkuFacsDA8ZtViv1gi+onBxMhEMIaGyQeGxBng==',
             'js/showdown-2.1.0.js'   => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
             'js/zlib-1.3.2.js'       => 'sha512-RAhJgxg9siMIA8ky4c10Rc2zUgnK80olHB8Tt1IOYWY4Eh1WmrviQkDn+sgBlb38ZHq3tzufGC41kP360gmosQ==',