use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class CommentDataUtil method createCommentData.
public static CommentData createCommentData(CommentDoc commentDoc) {
CommentData commentData = new CommentData(commentDoc.getId());
commentData.setUserId(commentDoc.getUserId());
commentData.setContent(commentDoc.getContent());
commentData.setCreationDate(commentDoc.getCreationDate());
commentData.setLastUpdated(commentDoc.getLastUpdated());
commentData.setLikeCount(commentDoc.getLikeCount());
commentData.setAccessToUpdate(hasAccessToUpdateCommentData(CommentState.ACTIVE, commentDoc.getUserId()));
commentData.setLiked(commentDoc.getLikedByUserIds().contains(AccessTokenFilter.getAccessToken().getUserId()));
return commentData;
}
use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class CommentApi method post.
@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
CommentData commentData = new CommentData(request.commentId);
commentData.setUserId(AccessTokenFilter.getAccessToken().getUserId());
commentData.setParentType(request.parentType);
commentData.setParentId(request.parentId);
if (request.hasContent)
commentData.setContent(request.content);
if (request.hasState)
commentData.setState(request.state);
else
commentData.setState(CommentState.ACTIVE);
commentData = CommentDataUtil.saveCommentData(commentData);
if (commentData.getReferenceType() == ReferenceType.PRATILIPI) {
Task task = TaskQueueFactory.newTask().setUrl("/pratilipi/process").addParam("pratilipiId", commentData.getReferenceId()).addParam("updateReviewsDoc", "true");
TaskQueueFactory.getPratilipiTaskQueue().add(task);
}
return new Response(commentData);
}
Aggregations