yes
This commit is contained in:
parent
b06fd84985
commit
20b4e20685
@ -36,7 +36,7 @@ public final class POSTServersHeartbeat implements Handler<RoutingContext> {
|
|||||||
public void handle(RoutingContext ctx) {
|
public void handle(RoutingContext ctx) {
|
||||||
Actor actor = ctx.get("actor");
|
Actor actor = ctx.get("actor");
|
||||||
|
|
||||||
if (actor.getType().isServer()) {
|
if (!actor.getType().isServer()) {
|
||||||
ErrorUtils.respondOther(ctx, 403, "This action can only be performed when requested by a server.", "serverOnly", ImmutableMap.of());
|
ErrorUtils.respondOther(ctx, 403, "This action can only be performed when requested by a server.", "serverOnly", ImmutableMap.of());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public final class POSTServersHeartbeat implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
CompositeFuture.all(
|
CompositeFuture.all(
|
||||||
createInfoResponse(actorServer, requestBody.getDouble("lastTps"), playerNames),
|
createInfoResponse(actorServer, requestBody.getDouble("lastTps"), playerNames),
|
||||||
createPlayerResponse(actorServer, playerNames, playerIps),
|
createPlayerResponse(actor, actorServer, playerNames, playerIps),
|
||||||
createPermissionsResponse(ServerGroup.findById(actorServer.getServerGroup())),
|
createPermissionsResponse(ServerGroup.findById(actorServer.getServerGroup())),
|
||||||
createEventsResponse(actorServer, requestBody.getJsonArray("events"))
|
createEventsResponse(actorServer, requestBody.getJsonArray("events"))
|
||||||
).setHandler((result) -> {
|
).setHandler((result) -> {
|
||||||
@ -82,7 +82,7 @@ public final class POSTServersHeartbeat implements Handler<RoutingContext> {
|
|||||||
return callback;
|
return callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Future<Map<String, Object>> createPlayerResponse(Server server, Map<UUID, String> playerNames, Map<UUID, String> playerIps) {
|
private Future<Map<String, Object>> createPlayerResponse(Actor actor, Server server, Map<UUID, String> playerNames, Map<UUID, String> playerIps) {
|
||||||
Future<Map<String, Object>> callback = Future.future();
|
Future<Map<String, Object>> callback = Future.future();
|
||||||
|
|
||||||
Future<Map<UUID, User>> userLookupCallback = Future.future();
|
Future<Map<UUID, User>> userLookupCallback = Future.future();
|
||||||
@ -114,7 +114,7 @@ public final class POSTServersHeartbeat implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
users.forEach((uuid, user) -> {
|
users.forEach((uuid, user) -> {
|
||||||
Future<Map<String, Object>> loginInfoFuture = Future.future();
|
Future<Map<String, Object>> loginInfoFuture = Future.future();
|
||||||
createLoginInfo(user, server, grants.get(uuid), punishments.get(uuid), prefixGrants.get(uuid), loginInfoFuture);
|
createLoginInfo(actor, user, server, grants.get(uuid), punishments.get(uuid), prefixGrants.get(uuid), loginInfoFuture);
|
||||||
loginInfoFutures.put(uuid, loginInfoFuture);
|
loginInfoFutures.put(uuid, loginInfoFuture);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -236,8 +236,9 @@ public final class POSTServersHeartbeat implements Handler<RoutingContext> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLoginInfo(User user, Server server, List<Grant> grants, List<Punishment> punishments, List<PrefixGrant> prefixGrants, Future<Map<String, Object>> callback) {
|
private void createLoginInfo(Actor actor, User user, Server server, List<Grant> grants, List<Punishment> punishments, List<PrefixGrant> prefixGrants, Future<Map<String, Object>> callback) {
|
||||||
if (user.seenOnServer(server)) {
|
|
||||||
|
if (actor.getType() == ActorType.SERVER && user.seenOnServer(server)) {
|
||||||
user.save((ignored, error) -> {
|
user.save((ignored, error) -> {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
callback.fail(error);
|
callback.fail(error);
|
||||||
|
@ -63,8 +63,10 @@ public final class POSTUsersIdLogin implements Handler<RoutingContext> {
|
|||||||
ErrorUtils.respondInternalError(ctx, updateUsernameError);
|
ErrorUtils.respondInternalError(ctx, updateUsernameError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(actor.getType() == ActorType.SERVER) {
|
||||||
user.seenOnServer(actorServer);
|
user.seenOnServer(actorServer);
|
||||||
|
}
|
||||||
|
|
||||||
user.save((ignored3, saveUserError) -> {
|
user.save((ignored3, saveUserError) -> {
|
||||||
if (saveUserError != null) {
|
if (saveUserError != null) {
|
||||||
ErrorUtils.respondInternalError(ctx, saveUserError);
|
ErrorUtils.respondInternalError(ctx, saveUserError);
|
||||||
|
Loading…
Reference in New Issue
Block a user