mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
fe(payg): show the usage-limit modal when the limit is hit (direct + policy) (#6626)
This commit is contained in:
@@ -299,6 +299,10 @@ public class EntitlementGuard implements HandlerInterceptor {
|
||||
deniedDegradedCounter.increment();
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("error", "FEATURE_DEGRADED");
|
||||
// subscribed tells the client which usage-limit modal to show: a subscribed team is over
|
||||
// its spending cap; an un-subscribed one has spent its free allowance. (PAYG_LIMIT_REACHED
|
||||
// already carries this; mirror it here so the JWT/web path can pick the right modal too.)
|
||||
body.put("subscribed", snapshot.subscribed());
|
||||
body.put("missingGates", missingGates(required, snapshot.enabledGates()));
|
||||
body.put("state", snapshot.state().name());
|
||||
body.put(
|
||||
|
||||
+2
@@ -308,6 +308,8 @@ class EntitlementGuardTest {
|
||||
JsonNode body = json.readTree(res.getContentAsByteArray());
|
||||
assertThat(body.get("error").asText()).isEqualTo("FEATURE_DEGRADED");
|
||||
assertThat(body.get("state").asText()).isEqualTo("DEGRADED");
|
||||
// subscribed drives the client's modal choice (free-limit vs spend-cap).
|
||||
assertThat(body.get("subscribed").asBoolean()).isFalse();
|
||||
assertThat(body.get("capUnits").asLong()).isEqualTo(500L);
|
||||
assertThat(body.get("spendUnits").asLong()).isEqualTo(500L);
|
||||
assertThat(body.get("missingGates").isArray()).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user