Rank schema changes
This commit is contained in:
parent
d9d87872cb
commit
7f10888151
@ -27,13 +27,16 @@ public final class Rank {
|
||||
|
||||
@Getter @Id private String id;
|
||||
@Getter private String inheritsFromId;
|
||||
@Getter private int weight;
|
||||
@Getter private int generalWeight;
|
||||
@Getter private int displayWeight;
|
||||
@Getter private String displayName;
|
||||
@Getter private String gamePrefix;
|
||||
@Getter private String gameColor;
|
||||
@Getter private String websiteColor;
|
||||
@Getter private boolean staffRank;
|
||||
@Getter private boolean higherStaffRank;
|
||||
@Getter private boolean grantRequiresTotp;
|
||||
@Getter private String queueMessage;
|
||||
@Getter private boolean queueInstantJoin;
|
||||
|
||||
public static List<Rank> findAll() {
|
||||
return ImmutableList.copyOf(rankCache);
|
||||
@ -67,16 +70,20 @@ public final class Rank {
|
||||
|
||||
private Rank() {} // For Jackson
|
||||
|
||||
public Rank(String id, String inheritsFromId, int weight, String displayName, String gamePrefix, String gameColor, String websiteColor, boolean staffRank, boolean higherStaffRank) {
|
||||
public Rank(String id, String inheritsFromId, int generalWeight, int displayWeight, String displayName, String gamePrefix, String gameColor,
|
||||
String websiteColor, boolean staffRank, boolean grantRequiresTotp, String queueMessage, boolean queueInstantJoin) {
|
||||
this.id = id;
|
||||
this.inheritsFromId = inheritsFromId;
|
||||
this.weight = weight;
|
||||
this.generalWeight = generalWeight;
|
||||
this.displayWeight = displayWeight;
|
||||
this.displayName = displayName;
|
||||
this.gamePrefix = gamePrefix;
|
||||
this.gameColor = gameColor;
|
||||
this.websiteColor = websiteColor;
|
||||
this.staffRank = staffRank;
|
||||
this.higherStaffRank = higherStaffRank;
|
||||
this.grantRequiresTotp = grantRequiresTotp;
|
||||
this.queueMessage = queueMessage;
|
||||
this.queueInstantJoin = queueInstantJoin;
|
||||
}
|
||||
|
||||
public void insert(SingleResultCallback<Void> callback) {
|
||||
|
@ -651,7 +651,7 @@ public final class User {
|
||||
}
|
||||
|
||||
List<Rank> grantedRanksList = new ArrayList<>(grantedRanks);
|
||||
grantedRanksList.sort((a, b) -> Ints.compare(b.getWeight(), a.getWeight()));
|
||||
grantedRanksList.sort((a, b) -> Ints.compare(b.getGeneralWeight(), a.getGeneralWeight()));
|
||||
return ImmutableList.copyOf(grantedRanksList);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public final class POSTGrants implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rank.isHigherStaffRank()) {
|
||||
if (rank.isGrantRequiresTotp()) {
|
||||
int code = requestBody.getInteger("totpCode");
|
||||
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
|
||||
|
||||
|
@ -18,15 +18,18 @@ public final class POSTRanks implements Handler<RoutingContext> {
|
||||
JsonObject requestBody = ctx.getBodyAsJson();
|
||||
String id = requestBody.getString("id");
|
||||
String inheritsFromId = requestBody.getString("inheritsFromId");
|
||||
int weight = requestBody.getInteger("weight");
|
||||
int generalWeight = requestBody.getInteger("generalWeight");
|
||||
int displayWeight = requestBody.getInteger("displayWeight");
|
||||
String displayName = requestBody.getString("displayName");
|
||||
String gamePrefix = requestBody.getString("gamePrefix");
|
||||
String gameColor = requestBody.getString("gameColor");
|
||||
String websiteColor = requestBody.getString("websiteColor");
|
||||
boolean staffRank = requestBody.getBoolean("staffRank");
|
||||
boolean higherStaffRank = requestBody.getBoolean("higherStaffRank");
|
||||
boolean grantRequiresTotp = requestBody.getBoolean("grantRequiresTotp");
|
||||
String queueMessage = requestBody.getString("queueMessage");
|
||||
boolean queueInstantJoin = requestBody.getBoolean("queueInstantJoin");
|
||||
|
||||
Rank rank = new Rank(id, inheritsFromId, weight, displayName, gamePrefix, gameColor, websiteColor, staffRank, higherStaffRank);
|
||||
Rank rank = new Rank(id, inheritsFromId, generalWeight, displayWeight, displayName, gamePrefix, gameColor, websiteColor, staffRank, grantRequiresTotp, queueMessage, queueInstantJoin);
|
||||
SyncUtils.<Void>runBlocking(v -> rank.insert(v));
|
||||
|
||||
if (requestBody.containsKey("addedBy")) {
|
||||
|
@ -25,7 +25,7 @@ public final class GETStaff implements Handler<RoutingContext> {
|
||||
Rank firstRank = staffRanks.get(first);
|
||||
Rank secondRank = staffRanks.get(second);
|
||||
|
||||
return Integer.compare(firstRank.getWeight(), secondRank.getWeight());
|
||||
return Integer.compare(firstRank.getGeneralWeight(), secondRank.getGeneralWeight());
|
||||
});
|
||||
|
||||
List<Grant> staffGrants = SyncUtils.runBlocking(v -> Grant.findByRank(staffRanks.values(), v));
|
||||
|
Loading…
Reference in New Issue
Block a user