From 4fb2cebe8d618f15060d20e7418941a63d74a649 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 2 Feb 2023 20:35:48 +0100 Subject: [PATCH] fixed the comment object that was wrong --- .../networking/ws/methods/v2/Comments.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Comments.java b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Comments.java index 7af0089..fbe9552 100644 --- a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Comments.java +++ b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Comments.java @@ -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");