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();
case JS:
return apiUsageState.getJsExecState();
case EMAIL:
return apiUsageState.getEmailExecState();
case SMS:
return apiUsageState.getSmsExecState();
default:
return ApiUsageStateValue.ENABLED;
}
@ -145,6 +149,12 @@ public class TenantApiUsageState {
case JS:
apiUsageState.setJsExecState(value);
break;
case EMAIL:
apiUsageState.setEmailExecState(value);
break;
case SMS:
apiUsageState.setSmsExecState(value);
break;
}
return !currentValue.equals(value);
}

View File

@ -304,6 +304,9 @@ public class DefaultMailService implements MailService {
return "invoke";
case RE:
return "process";
case EMAIL:
case SMS:
return "send";
default:
throw new RuntimeException("Not implemented!");
}
@ -319,6 +322,9 @@ public class DefaultMailService implements MailService {
return "invoked";
case RE:
return "processed";
case EMAIL:
case SMS:
return "sent";
default:
throw new RuntimeException("Not implemented!");
}
@ -337,6 +343,10 @@ public class DefaultMailService implements MailService {
return valueInM + " out of " + thresholdInM + " allowed JavaScript functions";
case RE_EXEC_COUNT:
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:
throw new RuntimeException("Not implemented!");
}
@ -353,6 +363,10 @@ public class DefaultMailService implements MailService {
return "JavaScript functions " + getValueAsString(value) + " times";
case RE_EXEC_COUNT:
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:
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())));
apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
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);
List<TsKvEntry> profileThresholds = new ArrayList<>();