Add scopeRanks field to user login info, which contains their best ranks on each scope
This commit is contained in:
parent
b53ea83bb9
commit
74570ccbc0
@ -3,6 +3,7 @@ package net.frozenorb.apiv3.model;
|
|||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@ -346,7 +347,16 @@ public final class User {
|
|||||||
// db query, but we don't include the result because it's not used in
|
// db query, but we don't include the result because it's not used in
|
||||||
// Hydrogen at all (bnut probably will be later on)
|
// Hydrogen at all (bnut probably will be later on)
|
||||||
// result.put("user", this);
|
// result.put("user", this);
|
||||||
result.put("ranks", ranks.stream().map(Rank::getId).collect(Collectors.toList()));
|
result.put("ranks", Collections2.transform(ranks, Rank::getId));
|
||||||
|
|
||||||
|
Map<String, List<String>> scopeRanks = new HashMap<>();
|
||||||
|
|
||||||
|
for (ServerGroup scope : ServerGroup.findAll()) {
|
||||||
|
List<Rank> ranksOnScope = getRanksScoped(scope, grants);
|
||||||
|
scopeRanks.put(scope.getId(), Collections2.transform(ranksOnScope, Rank::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("scopeRanks", scopeRanks);
|
||||||
|
|
||||||
if (activeMute != null) {
|
if (activeMute != null) {
|
||||||
result.put("mute", activeMute);
|
result.put("mute", activeMute);
|
||||||
@ -663,9 +673,7 @@ public final class User {
|
|||||||
grantedRanks.add(grantedRank);
|
grantedRanks.add(grantedRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grantedRanks.isEmpty()) {
|
|
||||||
grantedRanks.add(Rank.findById("default"));
|
grantedRanks.add(Rank.findById("default"));
|
||||||
}
|
|
||||||
|
|
||||||
if (registeredAt != null) {
|
if (registeredAt != null) {
|
||||||
grantedRanks.add(Rank.findById("registered"));
|
grantedRanks.add(Rank.findById("registered"));
|
||||||
|
Loading…
Reference in New Issue
Block a user