Slightly optimize number of db queries used in POST /users/:id/leave
This commit is contained in:
parent
439f92f596
commit
a39a1801e4
@ -26,10 +26,15 @@ public class POSTUsersIdLeave implements Handler<RoutingContext> {
|
||||
User.findById(ctx.request().getParam("id"), ((user, error) -> {
|
||||
if (error != null) {
|
||||
ErrorUtils.respondInternalError(ctx, error);
|
||||
} else if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
ErrorUtils.respondNotFound(ctx, "User", ctx.request().getParam("id"));
|
||||
} else {
|
||||
user.leftServer(actorServer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.leftServer(actorServer)) {
|
||||
user.save((ignored, error2) -> {
|
||||
if (error2 != null) {
|
||||
ErrorUtils.respondInternalError(ctx, error2);
|
||||
|
Loading…
Reference in New Issue
Block a user