mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
- Add custom message support
This commit is contained in:
parent
9836ffdecf
commit
2f52856ea1
@ -20,6 +20,7 @@
|
|||||||
package com.wisemapping.mail;
|
package com.wisemapping.mail;
|
||||||
|
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.mail.javamail.MimeMessagePreparator;
|
import org.springframework.mail.javamail.MimeMessagePreparator;
|
||||||
@ -53,7 +54,7 @@ public final class Mailer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendEmail(final String from, final String to, final String subject, final Map model,
|
public void sendEmail(final String from, final String to, final String subject, final Map model,
|
||||||
final String templateMail) {
|
@NotNull final String templateMail) {
|
||||||
final MimeMessagePreparator preparator =
|
final MimeMessagePreparator preparator =
|
||||||
new MimeMessagePreparator() {
|
new MimeMessagePreparator() {
|
||||||
public void prepare(MimeMessage mimeMessage)
|
public void prepare(MimeMessage mimeMessage)
|
||||||
@ -63,11 +64,7 @@ public final class Mailer {
|
|||||||
message.setFrom(from);
|
message.setFrom(from);
|
||||||
message.setSubject(subject);
|
message.setSubject(subject);
|
||||||
|
|
||||||
final String messageBody =
|
final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail, model);
|
||||||
VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail,
|
|
||||||
model);
|
|
||||||
System.out.println(message);
|
|
||||||
|
|
||||||
message.setText(messageBody, true);
|
message.setText(messageBody, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -59,6 +59,7 @@ final public class NotificationService {
|
|||||||
model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
||||||
model.put("baseUrl", formMail);
|
model.put("baseUrl", formMail);
|
||||||
model.put("senderMail", user.getEmail());
|
model.put("senderMail", user.getEmail());
|
||||||
|
model.put("message", message);
|
||||||
|
|
||||||
|
|
||||||
mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
|
mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright [2011] [wisemapping]
|
* Copyright [2011] [wisemapping]
|
||||||
*
|
*
|
||||||
|
@ -227,9 +227,10 @@ public class MindmapController extends BaseController {
|
|||||||
// Is owner ?
|
// Is owner ?
|
||||||
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
||||||
if (role != CollaborationRole.OWNER) {
|
if (role != CollaborationRole.OWNER) {
|
||||||
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role);
|
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role, restCollabs.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove from the list of pendings to remove ...
|
||||||
if (collaboration != null) {
|
if (collaboration != null) {
|
||||||
collabsToRemove.remove(collaboration);
|
collabsToRemove.remove(collaboration);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||||||
public class RestCollaborationList {
|
public class RestCollaborationList {
|
||||||
|
|
||||||
private List<RestCollaboration> collaborations;
|
private List<RestCollaboration> collaborations;
|
||||||
|
private String message;
|
||||||
|
|
||||||
public RestCollaborationList() {
|
public RestCollaborationList() {
|
||||||
collaborations = new ArrayList<RestCollaboration>();
|
collaborations = new ArrayList<RestCollaboration>();
|
||||||
@ -46,4 +47,12 @@ public class RestCollaborationList {
|
|||||||
public void setCollaborations(@NotNull List<RestCollaboration> collaborations) {
|
public void setCollaborations(@NotNull List<RestCollaboration> collaborations) {
|
||||||
this.collaborations = collaborations;
|
this.collaborations = collaborations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public interface MindmapService {
|
|||||||
|
|
||||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||||
|
|
||||||
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message)
|
||||||
throws CollaborationException;
|
throws CollaborationException;
|
||||||
|
|
||||||
public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
|
||||||
|
@ -20,7 +20,6 @@ package com.wisemapping.service;
|
|||||||
|
|
||||||
import com.wisemapping.dao.MindmapManager;
|
import com.wisemapping.dao.MindmapManager;
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.mail.Mailer;
|
|
||||||
import com.wisemapping.mail.NotificationService;
|
import com.wisemapping.mail.NotificationService;
|
||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
@ -47,7 +46,7 @@ public class MindmapServiceImpl
|
|||||||
private NotificationService notificationService;
|
private NotificationService notificationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissions(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
||||||
final MindMap map = mindmapManager.getMindmapById(mapId);
|
final MindMap map = mindmapManager.getMindmapById(mapId);
|
||||||
return hasPermissions(user, map, grantedRole);
|
return hasPermissions(user, map, grantedRole);
|
||||||
}
|
}
|
||||||
@ -134,6 +133,7 @@ public class MindmapServiceImpl
|
|||||||
throw new IllegalArgumentException("The tile can not be empty");
|
throw new IllegalArgumentException("The tile can not be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//noinspection ConstantConditions
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalArgumentException("User can not be null");
|
throw new IllegalArgumentException("User can not be null");
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public class MindmapServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message)
|
||||||
throws CollaborationException {
|
throws CollaborationException {
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
@ -178,7 +178,7 @@ public class MindmapServiceImpl
|
|||||||
|
|
||||||
// Notify by email ...
|
// Notify by email ...
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
notificationService.newCollaboration(collaboration, mindmap, user, null);
|
notificationService.newCollaboration(collaboration, mindmap, user, message);
|
||||||
|
|
||||||
} else if (collaboration.getRole() != role) {
|
} else if (collaboration.getRole() != role) {
|
||||||
// If the relationship already exists and the role changed then only update the role
|
// If the relationship already exists and the role changed then only update the role
|
||||||
|
@ -23,12 +23,10 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 13px; background-color: #FFF; padding: 10px 7px 7px 7px; min-height: 100px">
|
<div style="font-size: 13px; background-color: #FFF; padding: 10px 7px 7px 7px; min-height: 100px">
|
||||||
#if( ! $message )
|
#if($message )
|
||||||
<p>${message}</p>
|
<pre style="font-family: Arial, sans-serif; color: #000; ">${message}</pre>
|
||||||
#end
|
#end
|
||||||
<p>Click to open: <a href="${mapEditUrl}">${mindmap.title}</a></p>
|
<p>Click to open: <a href="${mapEditUrl}">${mindmap.title}</a></p>
|
||||||
<br/>
|
|
||||||
|
|
||||||
<p style="color: #898989;">Do you have a WiseMapping account ?. Don't worry, you can create an account for
|
<p style="color: #898989;">Do you have a WiseMapping account ?. Don't worry, you can create an account for
|
||||||
free. </p>
|
free. </p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,13 +13,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#collabEmails {
|
#collabEmails {
|
||||||
float: left;
|
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#roleBtn {
|
#roleBtn {
|
||||||
float: left;
|
margin: 0 10px;
|
||||||
margin: 0px 10px;
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addBtn {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#collabMessage {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@ -38,7 +51,10 @@
|
|||||||
|
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<div id="errorMsg" class="alert alert-error"></div>
|
<div id="errorMsg" class="alert alert-error"></div>
|
||||||
<p>Add People: </p>
|
<div>
|
||||||
|
|
||||||
|
<p><strong>Add People:</strong></p>
|
||||||
|
|
||||||
<input type="text" id="collabEmails" name="collabEmails"
|
<input type="text" id="collabEmails" name="collabEmails"
|
||||||
placeholder="Enter collaborators emails separared by comas."/>
|
placeholder="Enter collaborators emails separared by comas."/>
|
||||||
|
|
||||||
@ -52,11 +68,26 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<button id="addBtn" class="btn btn-primary">Add</button>
|
<button id="addBtn" class="btn btn-primary">Add</button>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 10px;">
|
||||||
|
<p><strong>Notify people via email</strong> - <a href="#" id="addMessageLink">Add message</a></p>
|
||||||
|
<textarea cols="4" id="collabMessage" placeholder="Optional: Include a personal message">
|
||||||
|
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$("#errorMsg").hide();
|
$("#errorMsg").hide();
|
||||||
|
$("#collabMessage").hide();
|
||||||
|
|
||||||
|
$("#addMessageLink").click(function(event) {
|
||||||
|
$("#collabMessage").toggle().val("");
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
var messages = {
|
var messages = {
|
||||||
owner: 'Is owner',
|
owner: 'Is owner',
|
||||||
editor: 'Can edit',
|
editor: 'Can edit',
|
||||||
@ -248,6 +279,7 @@ var submitDialogForm = function() {
|
|||||||
collabs.collaborations = jQuery.grep(collabs.collaborations, function() {
|
collabs.collaborations = jQuery.grep(collabs.collaborations, function() {
|
||||||
return this.role != 'owner';
|
return this.role != 'owner';
|
||||||
});
|
});
|
||||||
|
collabs['message'] = $("#collabMessage").val();
|
||||||
|
|
||||||
jQuery.ajax("service/maps/${mindmap.id}/collabs", {
|
jQuery.ajax("service/maps/${mindmap.id}/collabs", {
|
||||||
async:false,
|
async:false,
|
||||||
|
Loading…
Reference in New Issue
Block a user