Add rank id conversion and properly update rank cache
This commit is contained in:
parent
846a7210bd
commit
199072b5fb
@ -323,16 +323,26 @@ public final class APIv3 {
|
||||
public void apply(Document grant) {
|
||||
UUID target = mongoIdToUUID.get(((DBRef) grant.get("target")).getId());
|
||||
|
||||
if (target == null || grant.getString("role").equalsIgnoreCase("unban") || grant.getString("role").equalsIgnoreCase("pass")) {
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String rank = grant.getString("role");
|
||||
|
||||
if (rank.equalsIgnoreCase("unban") || rank.equalsIgnoreCase("pass") || rank.equalsIgnoreCase("pink") || rank.equalsIgnoreCase("jrdev")) {
|
||||
return;
|
||||
} else if (rank.equalsIgnoreCase("high_roller")) {
|
||||
rank = "high-roller";
|
||||
} else if (rank.equalsIgnoreCase("dev")) {
|
||||
rank = "developer";
|
||||
}
|
||||
|
||||
Grant created = new Grant(
|
||||
new ObjectId().toString(),
|
||||
target,
|
||||
grant.containsKey("comment") ? grant.getString("comment") : "",
|
||||
grant.containsKey("scope") ? ImmutableSet.copyOf((Collection<String>) grant.get("scope")) : ImmutableSet.of(),
|
||||
grant.getString("role"),
|
||||
rank,
|
||||
grant.getDate("expires"),
|
||||
grant.containsKey("addedBy") ? mongoIdToUUID.get(((DBRef) grant.get("addedBy")).getId()) : null,
|
||||
grant.containsKey("created") ? grant.getDate("created") : new Date(),
|
||||
|
@ -31,6 +31,7 @@ public final class Rank {
|
||||
}
|
||||
|
||||
public static List<Rank> values() {
|
||||
updateCacheIfNeeded();
|
||||
return ImmutableList.copyOf(rankCache.values());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user