From c830372f2927a1021e9826bc580fad6b482dd371 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Fri, 17 Jun 2016 01:11:45 -0400 Subject: [PATCH] Add GET /user/:id/punishments --- .../apiv3/route/users/GETUserPermissions.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/net/frozenorb/apiv3/route/users/GETUserPermissions.java diff --git a/src/main/java/net/frozenorb/apiv3/route/users/GETUserPermissions.java b/src/main/java/net/frozenorb/apiv3/route/users/GETUserPermissions.java new file mode 100644 index 0000000..8aa2425 --- /dev/null +++ b/src/main/java/net/frozenorb/apiv3/route/users/GETUserPermissions.java @@ -0,0 +1,23 @@ +package net.frozenorb.apiv3.route.users; + +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; +import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.model.Punishment; +import net.frozenorb.apiv3.model.User; +import net.frozenorb.apiv3.util.ErrorUtils; + +public final class GETUserPermissions implements Handler { + + public void handle(RoutingContext ctx) { + User target = User.findByIdSync(ctx.request().getParam("id")); + + if (target == null) { + ErrorUtils.respondNotFound(ctx, "User", ctx.request().getParam("id")); + return; + } + + APIv3.respondJson(ctx, target.getGlobalPermissions()); + } + +} \ No newline at end of file