/** * Render the page with the form for the reply with quoting to original message. * The form has the next filled fields: recipient, title, message * * @param id {@link PrivateMessage} id * @return {@code ModelAndView} with the message having filled recipient, title, message fields * @throws NotFoundException when message not found */ @RequestMapping(value = "/quote/{pmId}", method = RequestMethod.GET) public ModelAndView quotePage(@PathVariable(PM_ID) Long id) throws NotFoundException { PrivateMessage pm = pmService.get(id); PrivateMessageDto dto = PrivateMessageDto.getReplyDtoFor(pm); dto.setBody(bbCodeService.quote(pm.getBody(), pm.getUserFrom())); return new ModelAndView(PM_FORM).addObject(DTO, dto); }
/** * Create the reply private message dto from {@link PrivateMessage} * @param pm private message for conversion in to reply * @return dto for reply */ public static PrivateMessageDto getReplyDtoFor(PrivateMessage pm) { PrivateMessageDto dto = new PrivateMessageDto(); dto.setRecipient(pm.getUserFrom().getUsername()); dto.setTitle(pm.prepareTitleForReply()); return dto; } }
private boolean hasCurrentUserAccessToPM(PrivateMessage privateMessage) throws NotFoundException { JCUser currentUser = userService.getCurrentUser(); PrivateMessageStatus messageStatus = privateMessage.getStatus(); if (currentUser.equals(privateMessage.getUserFrom()) && (messageStatus.equals(PrivateMessageStatus.DELETED_FROM_OUTBOX))) { return false; } return !(currentUserIsAuthor(currentUser, privateMessage) && (messageStatus.equals(PrivateMessageStatus.DELETED_FROM_INBOX))); }
break; case SENT: if (currentUser.equals(message.getUserFrom())) { message.setStatus(PrivateMessageStatus.DELETED_FROM_OUTBOX); result = "outbox";