Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
adding option to globally disable welcome email
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry de Graaff committed Apr 19, 2021
1 parent 11c767c commit 0313d74
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 28 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Setting up Zimbra
adminpassword=adminPassword
rocketurl=https://rocket.example.org
loginurl=https://zimbra.example.org
enableWelcomeEmail=true

- The `adminuser` and `adminpassword` should have been created
when you first installed Rocket Chat.
Expand Down
79 changes: 62 additions & 17 deletions extension/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified extension/build/tk/barrydegraaff/rocket/Rocket.class
Binary file not shown.
Binary file modified extension/rocket.jar
Binary file not shown.
25 changes: 14 additions & 11 deletions extension/src/tk/barrydegraaff/rocket/Rocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public String getPath() {
private String rocketURL;
private String loginurl;
private Boolean isMobile;
private String enableWelcomeEmail;

/**
* Processes HTTP POST requests.
Expand Down Expand Up @@ -372,6 +373,7 @@ public Boolean initializeRocketAPI() {
this.adminPassword = prop.getProperty("adminpassword");
this.rocketURL = prop.getProperty("rocketurl");
this.loginurl = prop.getProperty("loginurl");
this.enableWelcomeEmail = prop.getProperty("enableWelcomeEmail"); //may be null
input.close();
} catch (Exception ex) {
ex.printStackTrace();
Expand Down Expand Up @@ -551,20 +553,21 @@ public Boolean createUser(Account account) {

private void sendConfirmation(Account account, String username, String password) {
try {
MimeMessage mm = new Mime.FixedMimeMessage(JMSession.getSmtpSession(account));
if (!"false".equals(this.enableWelcomeEmail)) {
MimeMessage mm = new Mime.FixedMimeMessage(JMSession.getSmtpSession(account));
String to = account.getName();

String to = account.getName();
mm.setRecipient(javax.mail.Message.RecipientType.TO, new JavaMailInternetAddress(to));
mm.setContent("Your Rocket.Chat account has been created!<br><br>You must log-on to Rocket.Chat using your Zimbra credentials.<br>For changes to crucial settings inside RocketChat you may need these additional credentials:<br><br>Username: " + username + "<br>Password: " + password, MimeConstants.CT_TEXT_HTML);
mm.setSubject("Welcome to Rocket Chat");
mm.saveChanges();

mm.setRecipient(javax.mail.Message.RecipientType.TO, new JavaMailInternetAddress(to));
mm.setContent("Your Rocket.Chat account has been created!<br><br>You must log-on to Rocket.Chat using your Zimbra credentials.<br>For changes to crucial settings inside RocketChat you may need these additional credentials:<br><br>Username: " + username + "<br>Password: " + password, MimeConstants.CT_TEXT_HTML);
mm.setSubject("Welcome to Rocket Chat");
mm.saveChanges();
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
MailSender mailSender = mbox.getMailSender();

Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
MailSender mailSender = mbox.getMailSender();

mailSender.setSaveToSent(false);
mailSender.sendMimeMessage(null, mbox, mm);
mailSender.setSaveToSent(false);
mailSender.sendMimeMessage(null, mbox, mm);
}

} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 0313d74

Please sign in to comment.