fixed the comment object that was wrong
This commit is contained in:
parent
60e025cb5a
commit
4fb2cebe8d
|
@ -193,21 +193,11 @@ public class Comments {
|
|||
String context = ScopeProvider.instance.get();
|
||||
ResponseBean responseBean = new ResponseBean();
|
||||
Status status = Status.OK;
|
||||
//check that the postId exists first
|
||||
String postId = comment.getPostid();
|
||||
try {
|
||||
CassandraConnection.getInstance().getDatabookStore().readPost(postId);
|
||||
} catch(Exception e){
|
||||
responseBean.setMessage("You're probably trying comment a post with id " + postId + " that does not exist ");
|
||||
responseBean.setSuccess(false);
|
||||
status = Status.INTERNAL_SERVER_ERROR;
|
||||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
SocialMessageParser messageParser = new SocialMessageParser(comment.getText());
|
||||
String escapedCommentText = messageParser.getParsedMessage();
|
||||
// parse
|
||||
String key = UUID.randomUUID().toString();
|
||||
String postId = comment.getPostid();
|
||||
String commentText = escapedCommentText;
|
||||
String userid = username;
|
||||
Date time = new Date();
|
||||
|
@ -227,15 +217,13 @@ public class Comments {
|
|||
}
|
||||
String fullName = user.getFirstName() + " " + user.getLastName();
|
||||
String thumbnailURL = user.getUserAvatarURL();
|
||||
|
||||
Date lastEditTime = null;
|
||||
|
||||
Comment theComment = new Comment(key, userid, lastEditTime, userid, commentText, fullName, thumbnailURL);
|
||||
Comment theComment = new Comment(key, userid, time, postId, commentText, fullName, thumbnailURL);
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
result = CassandraConnection.getInstance().getDatabookStore().addComment(theComment);
|
||||
logger.info("Added comment? " + comment.toString() + " Result is " +result);
|
||||
logger.info("Added comment? " + theComment.toString() + " Result is " +result);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
responseBean.setMessage("Could not reach the DB to write the comment, something went wrong");
|
||||
|
|
Loading…
Reference in New Issue