Skip to content
Snippets Groups Projects
Commit ee69df8f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

filtering by removed added,

only admin can see unpinned comments in API
parent 16791dd5
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -25,8 +25,8 @@ public class CommentController extends BaseController {
@RequestMapping(value = "/getCommentList", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public List<Map<String, Object>> getOverlayList(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId,
@RequestParam(value = "columns", defaultValue = "") String columns, @RequestParam(value = "elementId", defaultValue = "") String elementId,
@RequestParam(value = "elementType", defaultValue = "") String elementType) throws SecurityException, QueryException {
return commentController.getCommentList(token, projectId, columns, elementId, elementType);
@RequestParam(value = "elementType", defaultValue = "") String elementType,@RequestParam(value = "removed", defaultValue = "") String removed) throws SecurityException, QueryException {
return commentController.getCommentList(token, projectId, columns, elementId, elementType,removed);
}
@RequestMapping(value = "/addComment", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
......
......@@ -49,7 +49,7 @@ public class CommentRestImpl {
@Autowired
private ElementDao elementDao;
public List<Map<String, Object>> getCommentList(String token, String projectId, String columns, String elementId, String elementType)
public List<Map<String, Object>> getCommentList(String token, String projectId, String columns, String elementId, String elementType, String removed)
throws SecurityException, QueryException {
AuthenticationToken authenticationToken = userService.getToken(token);
Model model = modelService.getLastModelByProjectId(projectId, authenticationToken);
......@@ -80,6 +80,13 @@ public class CommentRestImpl {
Object id = getId(comment).toString();
reject |= (!elementId.equals(id));
}
if (!"".equals(removed)) {
boolean expectedRemoved = removed.equalsIgnoreCase("true");
reject |= (comment.isDeleted() != expectedRemoved);
}
if (!isAdmin) {
reject |= (!comment.isPinned());
}
if (!reject) {
result.add(preparedComment(comment, columnsSet, isAdmin));
}
......@@ -260,13 +267,13 @@ public class CommentRestImpl {
columnsSet.add("icon");
columnsSet.add("type");
columnsSet.add("content");
columnsSet.add("pinned");
columnsSet.add("removed");
columnsSet.add("coord");
columnsSet.add("modelId");
columnsSet.add("elementId");
columnsSet.add("id");
if (admin) {
columnsSet.add("pinned");
columnsSet.add("author");
columnsSet.add("email");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment