use of org.thingsboard.rule.engine.api.sms.SmsSender in project thingsboard by thingsboard.
the class DefaultSmsService method sendTestSms.
@Override
public void sendTestSms(TestSmsRequest testSmsRequest) throws ThingsboardException {
SmsSender testSmsSender;
try {
testSmsSender = this.smsSenderFactory.createSmsSender(testSmsRequest.getProviderConfiguration());
} catch (Exception e) {
throw handleException(e);
}
this.sendSms(testSmsSender, testSmsRequest.getNumberTo(), testSmsRequest.getMessage());
testSmsSender.destroy();
}
use of org.thingsboard.rule.engine.api.sms.SmsSender in project thingsboard by thingsboard.
the class DefaultSmsService method updateSmsConfiguration.
@Override
public void updateSmsConfiguration() {
AdminSettings settings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "sms");
if (settings != null) {
try {
JsonNode jsonConfig = settings.getJsonValue();
SmsProviderConfiguration configuration = JacksonUtil.convertValue(jsonConfig, SmsProviderConfiguration.class);
SmsSender newSmsSender = this.smsSenderFactory.createSmsSender(configuration);
if (this.smsSender != null) {
this.smsSender.destroy();
}
this.smsSender = newSmsSender;
} catch (Exception e) {
log.error("Failed to create SMS sender", e);
}
}
}
Aggregations