mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	custom_email: Add manage_preferences block to the plaintext version.
Earlier, the content of the "manage_preferences" block that includes the unsubscribe_link, personal settings link, etc was missing in the plaintext version of the custom emails. This commit updates the logic to include the manage_preferences block content in the plaintext version.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							e967226f8c
						
					
				
				
					commit
					e8349aa5d7
				
			@@ -0,0 +1,15 @@
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
{% if remote_server_email %}
 | 
			
		||||
You are receiving this email to update you about important changes to Zulip's Terms of Service.
 | 
			
		||||
 | 
			
		||||
Unsubscribe: {{ unsubscribe_link }}
 | 
			
		||||
{% elif unsubscribe_link %}
 | 
			
		||||
{{ _("Manage email preferences") }}:
 | 
			
		||||
 | 
			
		||||
{{ realm_url }}/#settings/notifications
 | 
			
		||||
 | 
			
		||||
{{ _("Unsubscribe from marketing emails") }}:
 | 
			
		||||
 | 
			
		||||
{{ unsubscribe_link }}
 | 
			
		||||
{% endif %}
 | 
			
		||||
@@ -560,6 +560,16 @@ def custom_email_sender(
 | 
			
		||||
        #     vary user-to-user
 | 
			
		||||
        f.write(base_template.read().replace("{{ rendered_input }}", rendered_input))
 | 
			
		||||
 | 
			
		||||
    # Add the manage_preferences block content in the plain_text template.
 | 
			
		||||
    manage_preferences_block_template_path = (
 | 
			
		||||
        "templates/zerver/emails/custom_email_base.pre.manage_preferences_block.txt"
 | 
			
		||||
    )
 | 
			
		||||
    with (
 | 
			
		||||
        open(plain_text_template_path, "a") as f,
 | 
			
		||||
        open(manage_preferences_block_template_path) as manage_preferences_block,
 | 
			
		||||
    ):
 | 
			
		||||
        f.write(manage_preferences_block.read())
 | 
			
		||||
 | 
			
		||||
    with open(subject_path, "w") as f:
 | 
			
		||||
        f.write(get_header(subject, parsed_email_template.get("subject"), "subject"))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,11 @@ class TestCustomEmails(ZulipTestCase):
 | 
			
		||||
            str(msg.alternatives[0][0]),
 | 
			
		||||
        )
 | 
			
		||||
        self.assertIn("Unsubscribe", str(msg.alternatives[0][0]))
 | 
			
		||||
        # Verify that the Text version contains the footer.
 | 
			
		||||
        self.assertIn(
 | 
			
		||||
            "You are receiving this email to update you about important changes to Zulip", msg.body
 | 
			
		||||
        )
 | 
			
		||||
        self.assertIn("Unsubscribe", msg.body)
 | 
			
		||||
 | 
			
		||||
    def test_send_custom_email_headers(self) -> None:
 | 
			
		||||
        hamlet = self.example_user("hamlet")
 | 
			
		||||
@@ -107,7 +112,7 @@ class TestCustomEmails(ZulipTestCase):
 | 
			
		||||
        msg = mail.outbox[0]
 | 
			
		||||
        self.assertEqual(msg.subject, "Test subject")
 | 
			
		||||
        self.assertFalse(msg.reply_to)
 | 
			
		||||
        self.assertEqual("Test body", msg.body)
 | 
			
		||||
        self.assertIn("Test body", msg.body)
 | 
			
		||||
 | 
			
		||||
    def test_send_custom_email_context(self) -> None:
 | 
			
		||||
        hamlet = self.example_user("hamlet")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user