Add missing cases for email and sms api limits

This commit is contained in:
Igor Kulikov 2020-11-23 18:28:02 +02:00
parent d6c6a2e343
commit 04bb1e5f4f
3 changed files with 28 additions and 0 deletions

View File

@ -125,6 +125,10 @@ public class TenantApiUsageState {
return apiUsageState.getDbStorageState(); return apiUsageState.getDbStorageState();
case JS: case JS:
return apiUsageState.getJsExecState(); return apiUsageState.getJsExecState();
case EMAIL:
return apiUsageState.getEmailExecState();
case SMS:
return apiUsageState.getSmsExecState();
default: default:
return ApiUsageStateValue.ENABLED; return ApiUsageStateValue.ENABLED;
} }
@ -145,6 +149,12 @@ public class TenantApiUsageState {
case JS: case JS:
apiUsageState.setJsExecState(value); apiUsageState.setJsExecState(value);
break; break;
case EMAIL:
apiUsageState.setEmailExecState(value);
break;
case SMS:
apiUsageState.setSmsExecState(value);
break;
} }
return !currentValue.equals(value); return !currentValue.equals(value);
} }

View File

@ -304,6 +304,9 @@ public class DefaultMailService implements MailService {
return "invoke"; return "invoke";
case RE: case RE:
return "process"; return "process";
case EMAIL:
case SMS:
return "send";
default: default:
throw new RuntimeException("Not implemented!"); throw new RuntimeException("Not implemented!");
} }
@ -319,6 +322,9 @@ public class DefaultMailService implements MailService {
return "invoked"; return "invoked";
case RE: case RE:
return "processed"; return "processed";
case EMAIL:
case SMS:
return "sent";
default: default:
throw new RuntimeException("Not implemented!"); throw new RuntimeException("Not implemented!");
} }
@ -337,6 +343,10 @@ public class DefaultMailService implements MailService {
return valueInM + " out of " + thresholdInM + " allowed JavaScript functions"; return valueInM + " out of " + thresholdInM + " allowed JavaScript functions";
case RE_EXEC_COUNT: case RE_EXEC_COUNT:
return valueInM + " out of " + thresholdInM + " allowed Rule Engine messages"; return valueInM + " out of " + thresholdInM + " allowed Rule Engine messages";
case EMAIL_EXEC_COUNT:
return valueInM + " out of " + thresholdInM + " allowed Email messages";
case SMS_EXEC_COUNT:
return valueInM + " out of " + thresholdInM + " allowed SMS messages";
default: default:
throw new RuntimeException("Not implemented!"); throw new RuntimeException("Not implemented!");
} }
@ -353,6 +363,10 @@ public class DefaultMailService implements MailService {
return "JavaScript functions " + getValueAsString(value) + " times"; return "JavaScript functions " + getValueAsString(value) + " times";
case RE_EXEC_COUNT: case RE_EXEC_COUNT:
return getValueAsString(value) + " Rule Engine messages"; return getValueAsString(value) + " Rule Engine messages";
case EMAIL_EXEC_COUNT:
return getValueAsString(value) + " Email messages";
case SMS_EXEC_COUNT:
return getValueAsString(value) + " SMS messages";
default: default:
throw new RuntimeException("Not implemented!"); throw new RuntimeException("Not implemented!");
} }

View File

@ -96,6 +96,10 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A
new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
new StringDataEntry(ApiFeature.EMAIL.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
new StringDataEntry(ApiFeature.SMS.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
tsService.save(tenantId, saved.getId(), apiUsageStates, 0L); tsService.save(tenantId, saved.getId(), apiUsageStates, 0L);
List<TsKvEntry> profileThresholds = new ArrayList<>(); List<TsKvEntry> profileThresholds = new ArrayList<>();