Commit 04bb1e5f4f396efb62985bb274d7577620d82d4c
1 parent
d6c6a2e3
Add missing cases for email and sms api limits
Showing
3 changed files
with
28 additions
and
0 deletions
... | ... | @@ -125,6 +125,10 @@ public class TenantApiUsageState { |
125 | 125 | return apiUsageState.getDbStorageState(); |
126 | 126 | case JS: |
127 | 127 | return apiUsageState.getJsExecState(); |
128 | + case EMAIL: | |
129 | + return apiUsageState.getEmailExecState(); | |
130 | + case SMS: | |
131 | + return apiUsageState.getSmsExecState(); | |
128 | 132 | default: |
129 | 133 | return ApiUsageStateValue.ENABLED; |
130 | 134 | } |
... | ... | @@ -145,6 +149,12 @@ public class TenantApiUsageState { |
145 | 149 | case JS: |
146 | 150 | apiUsageState.setJsExecState(value); |
147 | 151 | break; |
152 | + case EMAIL: | |
153 | + apiUsageState.setEmailExecState(value); | |
154 | + break; | |
155 | + case SMS: | |
156 | + apiUsageState.setSmsExecState(value); | |
157 | + break; | |
148 | 158 | } |
149 | 159 | return !currentValue.equals(value); |
150 | 160 | } | ... | ... |
... | ... | @@ -304,6 +304,9 @@ public class DefaultMailService implements MailService { |
304 | 304 | return "invoke"; |
305 | 305 | case RE: |
306 | 306 | return "process"; |
307 | + case EMAIL: | |
308 | + case SMS: | |
309 | + return "send"; | |
307 | 310 | default: |
308 | 311 | throw new RuntimeException("Not implemented!"); |
309 | 312 | } |
... | ... | @@ -319,6 +322,9 @@ public class DefaultMailService implements MailService { |
319 | 322 | return "invoked"; |
320 | 323 | case RE: |
321 | 324 | return "processed"; |
325 | + case EMAIL: | |
326 | + case SMS: | |
327 | + return "sent"; | |
322 | 328 | default: |
323 | 329 | throw new RuntimeException("Not implemented!"); |
324 | 330 | } |
... | ... | @@ -337,6 +343,10 @@ public class DefaultMailService implements MailService { |
337 | 343 | return valueInM + " out of " + thresholdInM + " allowed JavaScript functions"; |
338 | 344 | case RE_EXEC_COUNT: |
339 | 345 | return valueInM + " out of " + thresholdInM + " allowed Rule Engine messages"; |
346 | + case EMAIL_EXEC_COUNT: | |
347 | + return valueInM + " out of " + thresholdInM + " allowed Email messages"; | |
348 | + case SMS_EXEC_COUNT: | |
349 | + return valueInM + " out of " + thresholdInM + " allowed SMS messages"; | |
340 | 350 | default: |
341 | 351 | throw new RuntimeException("Not implemented!"); |
342 | 352 | } |
... | ... | @@ -353,6 +363,10 @@ public class DefaultMailService implements MailService { |
353 | 363 | return "JavaScript functions " + getValueAsString(value) + " times"; |
354 | 364 | case RE_EXEC_COUNT: |
355 | 365 | return getValueAsString(value) + " Rule Engine messages"; |
366 | + case EMAIL_EXEC_COUNT: | |
367 | + return getValueAsString(value) + " Email messages"; | |
368 | + case SMS_EXEC_COUNT: | |
369 | + return getValueAsString(value) + " SMS messages"; | |
356 | 370 | default: |
357 | 371 | throw new RuntimeException("Not implemented!"); |
358 | 372 | } | ... | ... |
... | ... | @@ -96,6 +96,10 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A |
96 | 96 | new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); |
97 | 97 | apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), |
98 | 98 | new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); |
99 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
100 | + new StringDataEntry(ApiFeature.EMAIL.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
101 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
102 | + new StringDataEntry(ApiFeature.SMS.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
99 | 103 | tsService.save(tenantId, saved.getId(), apiUsageStates, 0L); |
100 | 104 | |
101 | 105 | List<TsKvEntry> profileThresholds = new ArrayList<>(); | ... | ... |