forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-33118 mailsend: add plain text only option (sakaiproject#9931)
add a config option to send the email as plain text only. When the option is selected, the CKEditor will change to the source view Also contains code cleanup along the way.
- Loading branch information
Showing
8 changed files
with
64 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
import org.sakaiproject.content.api.ContentHostingService; | ||
import org.sakaiproject.content.api.ContentResource; | ||
import org.sakaiproject.email.api.Attachment; | ||
import org.sakaiproject.email.api.ContentType; | ||
import org.sakaiproject.email.api.EmailService; | ||
import org.sakaiproject.entity.api.EntityManager; | ||
import org.sakaiproject.entity.api.Reference; | ||
|
@@ -60,6 +61,7 @@ | |
import org.sakaiproject.mailarchive.api.MailArchiveService; | ||
import org.sakaiproject.mailsender.MailsenderException; | ||
import org.sakaiproject.mailsender.logic.ExternalLogic; | ||
import org.sakaiproject.mailsender.model.ConfigEntry; | ||
import org.sakaiproject.site.api.Site; | ||
import org.sakaiproject.site.api.SiteService; | ||
import org.sakaiproject.tool.api.SessionManager; | ||
|
@@ -291,17 +293,29 @@ public void sendMailNullTo() throws Exception { | |
@Test(expected = MailsenderException.class) | ||
public void sendMailEmptyTo() throws Exception { | ||
impl.sendEmail(null, "[email protected]", null, | ||
new HashMap<String, String>(), null, null, null); | ||
new HashMap<>(), null, null, null); | ||
fail("Must define 'to'"); | ||
} | ||
|
||
@Test | ||
public void sendMailRequiredArgs() throws Exception { | ||
HashMap<String, String> to = new HashMap<String, String>(); | ||
HashMap<String, String> to = new HashMap<>(); | ||
to.put("test", "test"); | ||
impl.sendEmail(null, "[email protected]", null, to, null, null, null); | ||
} | ||
|
||
@Test | ||
public void sendPlainTextOnly() throws Exception { | ||
// create config with onlyPlainText | ||
ConfigEntry config = new ConfigEntry(); | ||
config.setOnlyPlainText(true); | ||
// sendEmail | ||
HashMap<String, String> to = new HashMap<>(); | ||
to.put("test", "test"); | ||
impl.sendEmail(null, "[email protected]", null, to, null, null, null); | ||
verify(emailService).send(argThat(emailMessage -> ContentType.TEXT_PLAIN.equals(emailMessage.getContentType())), anyBoolean()); | ||
} | ||
|
||
@Test | ||
public void emailArchiveIsNotAddedToSite() throws Exception { | ||
MailArchiveChannel channel = mock(MailArchiveChannel.class); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters