aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Messages.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/Messages.java b/juick-server/src/main/java/com/juick/server/api/Messages.java
index 69cf828c..1c3062af 100644
--- a/juick-server/src/main/java/com/juick/server/api/Messages.java
+++ b/juick-server/src/main/java/com/juick/server/api/Messages.java
@@ -22,6 +22,7 @@ import com.juick.Tag;
import com.juick.User;
import com.juick.server.Utils;
import com.juick.server.component.MessageReadEvent;
+import com.juick.server.helpers.CommandResult;
import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.UserUtils;
import com.juick.service.MessagesService;
@@ -80,7 +81,7 @@ public class Messages {
return FORBIDDEN;
}
- @RequestMapping("/messages")
+ @GetMapping("/messages")
public ResponseEntity<List<com.juick.Message>> getMessages(
@RequestParam(required = false) String uname,
@RequestParam(name = "before_mid", defaultValue = "0") Integer before,
@@ -138,6 +139,19 @@ public class Messages {
}
return ResponseEntity.ok(messagesService.getMessages(mids));
}
+ @DeleteMapping("/messages")
+ public CommandResult deleteMessage(@RequestParam int mid, @RequestParam(required = false, defaultValue = "0") int rid) {
+ User visitor = UserUtils.getCurrentUser();
+ if (rid > 0) {
+ if (messagesService.deleteReply(visitor.getUid(), mid, rid)) {
+ return CommandResult.fromString("Reply deleted");
+ }
+ }
+ if (messagesService.deleteMessage(visitor.getUid(), mid)) {
+ return CommandResult.fromString("Message deleted");
+ }
+ throw new HttpBadRequestException();
+ }
@GetMapping("/messages/discussions")
public List<Message> getDiscussions(
@RequestParam(required = false, defaultValue = "0") Long to) {