Fix a few mistakes we made when passing callback results back up

This commit is contained in:
Colin McDonald 2016-06-30 17:29:28 -04:00
parent 968ceb1a1d
commit c1017f9241
2 changed files with 22 additions and 14 deletions

View File

@ -227,28 +227,34 @@ public final class User {
Grant.findByUser(this, new MongoToVertxCallback<>(grantsFuture));
CompositeFuture.all(punishmentsFuture, ipIntelFuture, ipBansFuture, grantsFuture).setHandler((result) -> {
if (result.succeeded()) {
Iterable<Punishment> punishments = result.result().result(0);
IpIntel ipIntel = result.result().result(1);
Iterable<IpBan> ipBans = result.result().result(2);
Iterable<Grant> grants = result.result().result(3);
getLoginInfo(server, ipIntel, punishments, ipBans, grants, (loginInfo, error) -> {
if (error != null) {
callback.onResult(null, error);
} else {
callback.onResult(loginInfo, null);
}
});
} else {
if (result.failed()) {
callback.onResult(null, result.cause());
return;
}
Iterable<Punishment> punishments = result.result().result(0);
IpIntel ipIntel = result.result().result(1);
Iterable<IpBan> ipBans = result.result().result(2);
Iterable<Grant> grants = result.result().result(3);
getLoginInfo(server, ipIntel, punishments, ipBans, grants, (loginInfo, error) -> {
if (error != null) {
callback.onResult(null, error);
} else {
callback.onResult(loginInfo, null);
}
});
});
}
// This is only used to help batch requests to mongo
public void getLoginInfo(Server server, IpIntel ipIntel, Iterable<Punishment> punishments, Iterable<IpBan> ipBans, Iterable<Grant> grants, SingleResultCallback<Map<String, Object>> callback) {
getAccessInfo(ipIntel, punishments, ipBans, (accessInfo, error) -> {
if (error != null) {
callback.onResult(null, error);
return;
}
ServerGroup serverGroup = ServerGroup.findById(server.getServerGroup());
Punishment activeMute = null;

View File

@ -41,6 +41,8 @@ public class POSTUsersIdLeave implements Handler<RoutingContext> {
APIv3.respondJson(ctx, 200, user);
}
});
} else {
APIv3.respondJson(ctx, 200, user);
}
}));
}