Available delivery methods check: don't check mail server connection

This commit is contained in:
ViacheslavKlimov 2023-04-25 14:31:09 +03:00
parent 0ce243f2e7
commit f44de42165
14 changed files with 20 additions and 15 deletions

View File

@ -364,6 +364,11 @@ public class DefaultMailService implements MailService {
mailSender.testConnection(); mailSender.testConnection();
} }
@Override
public boolean isConfigured(TenantId tenantId) {
return mailSender != null;
}
private String toEnabledValueLabel(ApiFeature apiFeature) { private String toEnabledValueLabel(ApiFeature apiFeature) {
switch (apiFeature) { switch (apiFeature) {
case DB: case DB:

View File

@ -49,10 +49,8 @@ public class EmailNotificationChannel implements NotificationChannel<User, Email
@Override @Override
public void check(TenantId tenantId) throws Exception { public void check(TenantId tenantId) throws Exception {
try { if (!mailService.isConfigured(tenantId)) {
mailService.testConnection(tenantId); throw new RuntimeException("Mail server is not configured");
} catch (Exception e) {
throw new RuntimeException("Mail server is not available");
} }
} }

View File

@ -54,4 +54,6 @@ public interface MailService {
void testConnection(TenantId tenantId) throws Exception; void testConnection(TenantId tenantId) throws Exception;
boolean isConfigured(TenantId tenantId);
} }

View File

@ -17,7 +17,7 @@ Available template parameters:
* `alarmOriginatorEntityType` - the entity type of the alarm originator, e.g. 'Device'; * `alarmOriginatorEntityType` - the entity type of the alarm originator, e.g. 'Device';
* `alarmOriginatorName` - the name of the alarm originator, e.g. 'Sensor T1'; * `alarmOriginatorName` - the name of the alarm originator, e.g. 'Sensor T1';
* `alarmOriginatorId` - the alarm originator entity id as uuid string; * `alarmOriginatorId` - the alarm originator entity id as uuid string;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -26,7 +26,7 @@ Available template parameters:
* `userFirstName` - first name of the user who made the action; * `userFirstName` - first name of the user who made the action;
* `userLastName` - last name of the user who made the action; * `userLastName` - last name of the user who made the action;
* `action` - one of: 'assigned', 'unassigned'; * `action` - one of: 'assigned', 'unassigned';
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -22,7 +22,7 @@ Available template parameters:
* `userEmail` - email of the user who made the action; * `userEmail` - email of the user who made the action;
* `userFirstName` - first name of the user who made the action; * `userFirstName` - first name of the user who made the action;
* `userLastName` - last name of the user who made the action; * `userLastName` - last name of the user who made the action;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -18,7 +18,7 @@ Available template parameters:
* `currentValue` - current number of used units; * `currentValue` - current number of used units;
* `tenantId` - id of the tenant; * `tenantId` - id of the tenant;
* `tenantName` - name of the tenant; * `tenantName` - name of the tenant;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -14,7 +14,7 @@ Available template parameters:
* `deviceLabel` - the device label; * `deviceLabel` - the device label;
* `deviceType` - the device type; * `deviceType` - the device type;
* `eventType` - one of: 'inactive', 'active'; * `eventType` - one of: 'inactive', 'active';
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -15,7 +15,7 @@ Available template parameters:
* `percents` - the percent from the notification rule configuration; * `percents` - the percent from the notification rule configuration;
* `tenantId` - id of the tenant; * `tenantId` - id of the tenant;
* `tenantName` - name of the tenant; * `tenantName` - name of the tenant;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -18,7 +18,7 @@ Available template parameters:
* `userEmail` - email of the user who made the action; * `userEmail` - email of the user who made the action;
* `userFirstName` - first name of the user who made the action; * `userFirstName` - first name of the user who made the action;
* `userLastName` - last name of the user who made the action; * `userLastName` - last name of the user who made the action;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -9,7 +9,7 @@ See the available types and parameters below:
Available template parameters: Available template parameters:
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -14,7 +14,7 @@ Available template parameters:
* `upgradeInstructionsUrl` - upgrade instructions link for latest version; * `upgradeInstructionsUrl` - upgrade instructions link for latest version;
* `currentVersion` - the current platform version * `currentVersion` - the current platform version
* `currentVersionReleaseNotesUrl` - release notes link for current version; * `currentVersionReleaseNotesUrl` - release notes link for current version;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -17,7 +17,7 @@ Available template parameters:
* `eventType` - one of: 'started', 'updated', 'stopped'; * `eventType` - one of: 'started', 'updated', 'stopped';
* `action` - one of: 'start', 'update', 'stop'; * `action` - one of: 'start', 'update', 'stop';
* `error` - the error text; * `error` - the error text;
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;

View File

@ -14,7 +14,7 @@ Available template parameters:
* `originatorType` - type of the originator, e.g. 'Device'; * `originatorType` - type of the originator, e.g. 'Device';
* `originatorId` - id of the originator * `originatorId` - id of the originator
* `msgType` - type of the message * `msgType` - type of the message
* `recipientTitle` - title of the recipient (first and last name if specified, email otherwise) * `recipientTitle` - title of the recipient (first and last name if specified, email otherwise);
* `recipientEmail` - email of the recipient; * `recipientEmail` - email of the recipient;
* `recipientFirstName` - first name of the recipient; * `recipientFirstName` - first name of the recipient;
* `recipientLastName` - last name of the recipient; * `recipientLastName` - last name of the recipient;