Skip to content

Commit

Permalink
update handleWordDeleteRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
SteVio89 committed Jul 16, 2024
1 parent de47005 commit 86e61f5
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,20 @@ private void handleWordDeleteRequest(HttpExchange httpExchange, Map<String, Stri
ensurePostMethod(httpExchange, "/words/delete");
UserLimits limits = getUserLimits(parameters, config);
DatabaseAccess db = DatabaseAccess.getInstance();
String dict = parameters.get("dict");
if(dict == null &&
limits.getAccount() != null &&
limits.getAccount().getDefaultDictionary() != null &&
!limits.getAccount().getDefaultDictionary().isEmpty()) {
dict = limits.getAccount().getDefaultDictionary();
}
boolean deleted;
if("batch".equals(parameters.get("mode"))) { //Experimental
List<String> words = Arrays.asList(parameters.get("words").split("\\s+"));
deleted = db.deleteWordBatch(words, limits.getPremiumUid(),parameters.get("dict"));
deleted = db.deleteWordBatch(words, limits.getPremiumUid(),dict);
writeResponse("deleted", deleted, httpExchange);
} else {
deleted = db.deleteWord(parameters.get("word"), limits.getPremiumUid(), parameters.get("dict"));
deleted = db.deleteWord(parameters.get("word"), limits.getPremiumUid(), dict);
writeResponse("deleted", deleted, httpExchange);
}
}
Expand Down

0 comments on commit 86e61f5

Please sign in to comment.