public MessageForm sendTutorShipOffer(MessageForm messageForm, User sender) {
   Message offerMessage = getMessageFromForm(messageForm, sender);
   tutorShipService.addOfferedTutorShip(offerMessage);
   offerMessage.setMessageSubject("Tutorship Offer");
   offerMessage = send(offerMessage);
   messageForm.setId(offerMessage.getId());
   return messageForm;
 }
 private Message getMessageFromForm(MessageForm messageForm, User sender) {
   Message message = new Message();
   User receiver = userDao.findByEmailLike(messageForm.getReceiver());
   if (receiver == null)
     throw new InvalidUserException("The user you want to send a message does not exist");
   message.setSender(sender);
   message.setReceiver(receiver);
   message.setMessageSubject(messageForm.getMessageSubject());
   message.setMessageText(messageForm.getMessageText());
   return message;
 }
 public Message sendTutorShipConfirmedMessage(User sender, User receiver) {
   Message acceptanceMessage = new Message();
   String messageText =
       new StringBuilder()
           .append("Your Tutorship for " + sender.getFirstName() + " was accepted by him!\n")
           .append("This message is auto generated. Do not answer")
           .toString();
   acceptanceMessage.setMessageText(messageText);
   acceptanceMessage.setMessageSubject("Tutorship accepted!");
   acceptanceMessage.setReceiver(receiver);
   acceptanceMessage.setSender(sender);
   return send(acceptanceMessage);
 }
 public void sendRatingReminder(Tutor tutor, User student) {
   Message reminder = new Message();
   reminder.setMessageText(
       "Don't forget to rate your tutor:"
           + "<br>"
           + "<a href=\"/tutoris_baernae/rate?tutorId="
           + tutor.getId()
           + "\"><u> Click here to rate your tutor </u></a>");
   reminder.setMessageSubject("Rate " + tutor.getStudent().getFirstName());
   reminder.setSender(tutor.getStudent());
   reminder.setReceiver(student);
   send(reminder);
 }
  public Message sendContactDetails(User sender, User receiver) {
    assert (!sender.equals(receiver));
    Message contactDetails = new Message();

    String allContactInformations =
        new StringBuilder()
            .append("You can contact me as follows: \n")
            .append("<br>Full name: " + sender.getFirstName() + " " + sender.getLastName() + " \n")
            .append("<br>Email: " + sender.getEmail() + " \n")
            .append("<br>This message is auto generated. Do not answer")
            .toString();
    contactDetails.setMessageSubject("Contact Details");
    contactDetails.setMessageText(allContactInformations);
    contactDetails.setReceiver(receiver);
    contactDetails.setSender(sender);
    return send(contactDetails);
  }