Browse Source

Remove Slack from user-level settings

pull/8878/head
ViacheslavKlimov 3 years ago
parent
commit
ea2d5485f4
  1. 6
      common/data/src/main/java/org/thingsboard/server/common/data/notification/NotificationDeliveryMethod.java
  2. 8
      common/data/src/main/java/org/thingsboard/server/common/data/notification/settings/UserNotificationSettings.java

6
common/data/src/main/java/org/thingsboard/server/common/data/notification/NotificationDeliveryMethod.java

@ -18,10 +18,6 @@ package org.thingsboard.server.common.data.notification;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
@RequiredArgsConstructor
public enum NotificationDeliveryMethod {
@ -33,6 +29,4 @@ public enum NotificationDeliveryMethod {
@Getter
private final String name;
public static final Set<NotificationDeliveryMethod> values = Arrays.stream(values()).collect(Collectors.toSet());
}

8
common/data/src/main/java/org/thingsboard/server/common/data/notification/settings/UserNotificationSettings.java

@ -39,6 +39,8 @@ public class UserNotificationSettings {
public static final UserNotificationSettings DEFAULT = new UserNotificationSettings(Collections.emptyMap());
private static final Set<NotificationDeliveryMethod> deliveryMethods = NotificationTargetType.PLATFORM_USERS.getSupportedDeliveryMethods();
@JsonCreator
public UserNotificationSettings(@JsonProperty("prefs") Map<NotificationType, NotificationPref> prefs) {
this.prefs = prefs;
@ -49,7 +51,7 @@ public class UserNotificationSettings {
if (pref != null) {
return pref.isEnabled() ? pref.getEnabledDeliveryMethods() : Collections.emptySet();
} else {
return NotificationDeliveryMethod.values;
return deliveryMethods;
}
}
@ -62,14 +64,14 @@ public class UserNotificationSettings {
public static NotificationPref createDefault() {
NotificationPref pref = new NotificationPref();
pref.setEnabled(true);
pref.setEnabledDeliveryMethods(NotificationDeliveryMethod.values);
pref.setEnabledDeliveryMethods(deliveryMethods);
return pref;
}
@JsonIgnore
@AssertTrue(message = "Only email, Web and SMS delivery methods are allowed")
public boolean isValid() {
return NotificationTargetType.PLATFORM_USERS.getSupportedDeliveryMethods().containsAll(enabledDeliveryMethods);
return deliveryMethods.containsAll(enabledDeliveryMethods);
}
}

Loading…
Cancel
Save