convs = DataManager.getAll(Conversation.class);
if (convs.size() == 0) {
- Conversation c = SavedData.create(Conversation.class);
+ Conversation c = Conversation.create();
convs.add(c); // TODO: Handle no conversation open
}
user.getConversations().add(convs.get(0));
diff --git a/src/io/github/norbipeti/chat/server/page/ReceiveMessageAjaxPage.java b/src/io/github/norbipeti/chat/server/page/ReceiveMessageAjaxPage.java
index 394962b..c886a31 100644
--- a/src/io/github/norbipeti/chat/server/page/ReceiveMessageAjaxPage.java
+++ b/src/io/github/norbipeti/chat/server/page/ReceiveMessageAjaxPage.java
@@ -27,21 +27,10 @@ public class ReceiveMessageAjaxPage extends Page {
public void handlePage(HttpExchange exchange) throws IOException {
User user = IOHelper.GetLoggedInUser(exchange);
if (user == null) {
- IOHelper.SendResponse(403, "Please log in to send messages
", exchange);
- return;
- }
- JsonObject obj = IOHelper.GetPOSTJSON(exchange);
- if (obj == null) {
- IOHelper.SendResponse(400, "JSONERROR: " + IOHelper.GetPOST(exchange), exchange);
- return;
- }
- if (!obj.has("message") || !obj.has("conversation")) {
- IOHelper.SendResponse(400,
- "400 Bad request
Message or conversation not found in JSON response.
"
- + IOHelper.GetPOST(exchange) + "
",
- exchange);
+ IOHelper.SendResponse(403, "Please log in to receive messages
", exchange);
return;
}
+ JsonObject obj = new JsonObject();
String message = obj.get("message").getAsString().trim();
int conversation = obj.get("conversation").getAsInt();
if (message.trim().length() == 0) {