if (isEmpty(comment)) {
return error(ErrorMessages.MISSING_REQUIRED_FIELD + "comment", Response.status(Response.Status.BAD_REQUEST));
}
User user = applicationManager.getSecurityService().getCurrentUser();
// check if the user added any tags
MessageUtils.ParsedMessage parsedMessage = MessageUtils.parseMessage(comment);
Set<String> hashtags = parsedMessage.getTags();
MessageComment messageComment = new MessageComment(user, parsedMessage.getMessage());
try {
SobaMessage sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
// this is now a conversation, so add that tag
hashtags.add("#conversation");
applicationManager.getMessageService().addCommentToMessage(user.getAccount(), sobaMessage.getId(), messageComment, hashtags);
} catch (MessageNotFoundException e) {
return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
}