Improve collaboration mail.
This commit is contained in:
@@ -39,19 +39,16 @@ public final class Mailer {
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
||||
public Mailer(String registrationEmail, String siteEmail)
|
||||
{
|
||||
public Mailer(String registrationEmail, String siteEmail) {
|
||||
this.registrationEmail = registrationEmail;
|
||||
this.siteEmail = siteEmail;
|
||||
}
|
||||
|
||||
public String getRegistrationEmail()
|
||||
{
|
||||
public String getRegistrationEmail() {
|
||||
return registrationEmail;
|
||||
}
|
||||
|
||||
public String getSiteEmail()
|
||||
{
|
||||
public String getSiteEmail() {
|
||||
return siteEmail;
|
||||
}
|
||||
|
||||
@@ -66,11 +63,12 @@ public final class Mailer {
|
||||
message.setFrom(from);
|
||||
message.setSubject(subject);
|
||||
|
||||
final String text =
|
||||
final String messageBody =
|
||||
VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail,
|
||||
model);
|
||||
System.out.println(message);
|
||||
|
||||
message.setText(text, true);
|
||||
message.setText(messageBody, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.mail;
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
final public class NotificationService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private Mailer mailer;
|
||||
private String baseUrl;
|
||||
|
||||
public NotificationService() {
|
||||
|
||||
}
|
||||
|
||||
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull MindMap mindmap, @NotNull User user, @Nullable String message) {
|
||||
|
||||
try {
|
||||
// Sent collaboration email ...
|
||||
final String formMail = mailer.getSiteEmail();
|
||||
|
||||
// Is the user already registered user ?.
|
||||
final String collabEmail = collaboration.getCollaborator().getEmail();
|
||||
|
||||
// Build the subject ...
|
||||
final String subject = user.getFullName() + " has shared a mindmap with you";
|
||||
|
||||
// Fill template properties ...
|
||||
final Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("mindmap", mindmap);
|
||||
model.put("message", "message");
|
||||
model.put("ownerName", user.getFirstname());
|
||||
model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
||||
model.put("baseUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
||||
|
||||
mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleException(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setMailer(Mailer mailer) {
|
||||
this.mailer = mailer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user