[openhabcloud] Support hiding notifications and tags (#16979)

* Support hiding notifications
See #16934

* Adds support for using tag over severity on extended actions

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Dan Cunningham 2024-07-04 05:06:33 -07:00 committed by Ciprian Pascu
parent d99bfd74bf
commit c9910a8efd
14 changed files with 611 additions and 108 deletions

View File

@ -108,17 +108,19 @@ The parameters for these actions have the following meaning:
- `emailAddress`: String containing the email address the target user is registered with in the cloud instance.
- `message`: String containing the notification message text.
- `icon`: String containing the icon name (as described in [Items: Icons]({{base}}/configuration/items.html#icons)).
- `severity`: String containing a description of the severity of the incident.
- `severity`: String containing a description of the severity (tag) of the incident.
`null` may be used to skip the `icon` or `severity` parameter.
### Title, Media Attachments & Actions
### Title, Tag, Reference Id, Media Attachments & Actions
The `sendNotification` and `sendBroadcastNotification` actions additionally support setting a title, media attachments and actions.
The `sendNotification` and `sendBroadcastNotification` actions additionally support setting a title, reference id, media attachments and actions.
The title is displayed as the notification title on the device and defaults to "openHAB" for the Android and iOS apps.
Media attachments are displayed together with the notification on the device and can be used to display images, e.g. a camera snapshot.
Actions allow the user to interact with the notification, e.g. to open a specific page in the app or to send a command to an Item.
- The tag is used for tagging messages for grouping when displaying in the app and to hide/remove groups of messages from a user's device. Tag was previously referred to as "severity".
- The title is displayed as the notification title on the device and defaults to "openHAB" for the Android and iOS apps.
- The reference id is a user supplied identifier that when set will replace messages with the same id on the user's device (so only the last version exists). It can be used to update or remove notifications.
- Media attachments are displayed together with the notification on the device and can be used to display images, e.g. a camera snapshot.
- Actions allow the user to interact with the notification, e.g. to open a specific page in the app or to send a command to an Item.
There are four different actions available:
@ -127,14 +129,16 @@ There are four different actions available:
To specify media attachments and actions, there is another variant of the `sendNotification` and `sendBroadcastNotification` actions:
- `sendNotification(emailAddress, message, icon, severity, title, onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3)`
- `sendBroadcastNotification(message, icon, severity, title, onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3)`
- `sendNotification(emailAddress, message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3)`
- `sendBroadcastNotification(message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3)`
The additional parameter for these variants have the following meaning:
- `tag` : A user supplied tag to group messages for removing using the `hideNotificationByTag` action or grouping messages when displayed in the app. This renames the `severity` parameter, both are functionally identical.
- `title`: The title of the notification. Defaults to "openHAB" inside the Android and iOS apps.
- `referenceId`: A user supplied id to both replace existing messages when pushed, and later remove messages with the `hideNotificationByReferenceId` actions.
- `onClickAction`: The action to be performed when the user clicks on the notification. Specified using the [action syntax](#action-syntax).
- `mediaAttachmentUrl`: The URL of the media attachment to be displayed with the notification. This URL must be reachable by the push notification client.
- `mediaAttachmentUrl`: The URL of the media attachment to be displayed with the notification. This can either be a fully qualified URL, prefixed with `http://` or `https://` and reachable by the client device, or an image item with the format `item:MyImageItem`
- `actionButton1`: The action to be performed when the user clicks on the first action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).
- `actionButton2`: The action to be performed when the user clicks on the second action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).
- `actionButton3`: The action to be performed when the user clicks on the third action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).
@ -151,6 +155,7 @@ There are two types of actions available:
- `ui`: Controls the UI in two possible ways:
- `ui:$path` where `$path` is either `/basicui/app?...` for navigating sitemaps (using the native renderer) or `/some/absolute/path` for navigating (using the web view).
- `ui:$commandItemSyntax` where `$commandItemSyntax` is the same syntax as used for the [UI Command Item]({{base}}/mainui/about.html#ui-command-item).
- `http:` or `https:` : Opens the fully qualified URL in an embedded browser on the device
Examples:
@ -160,6 +165,16 @@ Examples:
- `ui:/some/absolute/path`: Navigates to the absolut path `/some/absolute/path`.
- `ui:navigate:/page/my_floorplan_page`: Navigates Main UI to the page with the ID `my_floorplan_page`.
- `ui:popup:oh-clock-card`: Opens a popup with `oh-clock-card`.
- `https://openhab.org`: Opens an embedded browser to the site `https://openhab.org`
### Hide Notification Actions
There are also actions to hide existing notifications, either by `referenceId` or `tag` (formerly severity):
- `hideNotificationByReferenceId(emailAddress, referenceId)`
- `hideBroadcastNotificationByReferenceId(referenceId)`
- `hideNotificationByTag(emailAddress, tag)`
- `hideBroadcastNotificationByTag(tag)`
### Examples
@ -266,8 +281,8 @@ rule "Motion Detected Notification"
when
Item Apartment_MotionSensor changed to ON
then
sendBroadcastNotification("Motion detected in the apartment!", "motion", "MEDIUM",
"Motion Detected", null, "https://apartment.my/camera-snapshot.jpg",
sendBroadcastNotification("Motion detected in the apartment!", "motion", "Motion Tag",
"Motion Detected", "motion-id-1234", null, "https://apartment.my/camera-snapshot.jpg",
"Turn on the light=command:Apartment_Light:ON", null, null)
end
```
@ -280,8 +295,9 @@ end
rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
actions.notificationBuilder('Motion detected in the apartment!')
.withIcon('motion')
.withSeverity('MEDIUM')
.withTag('motion-tag')
.withTitle('Motion Detected')
.withReferenceId('motion-id-1234')
.withMediaAttachment('https://apartment.my/camera-snapshot.jpg')
.addActionButton('Turn on the light=command:Apartment_Light:ON')
.send();
@ -298,7 +314,7 @@ rule "Motion Detected Notification" do
run do
notify "Motion detected in the apartment!",
icon: "motion",
severity: "MEDIUM",
tag: "motion-tag",
title: "Motion Detected",
attachment: "https://apartment.my/camera-snapshot.jpg",
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }

View File

@ -52,13 +52,12 @@ public class NotificationAction {
* @param userId the cloud user id of the recipient
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
* @param tag for the notification (formerly severity)
*
*/
@ActionDoc(text = "Sends a push notification to mobile devices of user with userId")
public static void sendNotification(String userId, String message, @Nullable String icon,
@Nullable String severity) {
sendNotification(userId, message, icon, severity, null, null, null, null, null, null);
public static void sendNotification(String userId, String message, @Nullable String icon, @Nullable String tag) {
sendNotification(userId, message, icon, tag, null, null, null, null, null, null, null);
}
/**
@ -67,8 +66,9 @@ public class NotificationAction {
* @param userId the cloud user id of the recipient
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
* @param tag for the notification
* @param title for the notification
* @param referenceId an identifier used to collapse and hide notifications
* @param onClickAction the action to perform when clicked
* @param mediaAttachmentUrl the media to attach to a notification
* @param actionButton1 an action button in the format "Title=Action"
@ -77,13 +77,14 @@ public class NotificationAction {
*
*/
@ActionDoc(text = "Sends a push notification to mobile devices of user with userId")
public static void sendNotification(String userId, String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
public static void sendNotification(String userId, String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
logger.debug("sending notification '{}' to user {}", message, userId);
if (cloudService != null) {
cloudService.sendNotification(userId, message, icon, severity, title, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
cloudService.sendNotification(userId, message, icon, tag, title, referenceId, onClickAction,
mediaAttachmentUrl, actionButton1, actionButton2, actionButton3);
}
}
@ -105,14 +106,14 @@ public class NotificationAction {
*
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
* @param tag for the notification (formerly severity)
*
*/
@ActionDoc(text = "Sends a log notification which is shown in notifications log to all account users")
public static void sendLogNotification(String message, @Nullable String icon, @Nullable String severity) {
public static void sendLogNotification(String message, @Nullable String icon, @Nullable String tag) {
logger.debug("sending log notification '{}'", message);
if (cloudService != null) {
cloudService.sendLogNotification(message, icon, severity);
cloudService.sendLogNotification(message, icon, tag);
}
}
@ -134,12 +135,12 @@ public class NotificationAction {
*
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
* @param tag for the notification (formerly severity)
*
*/
@ActionDoc(text = "Sends a push notification to mobile devices of user with userId")
public static void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String severity) {
sendBroadcastNotification(message, icon, severity, null, null, null, null, null, null);
@ActionDoc(text = "Sends a broadcast notification to all mobile devices of all account users")
public static void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String tag) {
sendBroadcastNotification(message, icon, tag, null, null, null, null, null, null, null);
}
/**
@ -148,8 +149,9 @@ public class NotificationAction {
*
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
* @param tag for the notification
* @param title for the notification
* @param referenceId an identifier used to collapse and hide notifications
* @param onClickAction the action to perform when clicked
* @param mediaAttachmentUrl the media to attach to a notification
* @param actionButton1 an action button in the format "Title=Action"
@ -157,14 +159,69 @@ public class NotificationAction {
* @param actionButton3 an action button in the format "Title=Action"
*
*/
@ActionDoc(text = "Sends a push notification to mobile devices of user with userId")
public static void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
@ActionDoc(text = "Sends a broadcast notification to all mobile devices of all account users")
public static void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
logger.debug("sending broadcast notification '{}' to all users", message);
if (cloudService != null) {
cloudService.sendBroadcastNotification(message, icon, severity, title, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
cloudService.sendBroadcastNotification(message, icon, tag, title, referenceId, onClickAction,
mediaAttachmentUrl, actionButton1, actionButton2, actionButton3);
}
}
/**
* Hides notifications that contains a matching reference id to all mobile devices of a single user.
*
* @param userId the cloud user id of the recipient
* @param referenceId the user reference id
*
*/
@ActionDoc(text = "Hides notifications that contain the reference id on mobile devices of user with userId")
public static void hideNotificationByReferenceId(String userId, String referenceId) {
if (cloudService != null) {
cloudService.hideNotificationByReferenceId(userId, referenceId);
}
}
/**
* Hides notifications that contains a matching reference id to all mobile devices of all users of the account
*
* @param referenceId the user reference id
*
*/
@ActionDoc(text = "Hides notifications that contain the reference id on all mobile devices of all account users")
public static void hideBroadcastNotificationByReferenceId(String referenceId) {
if (cloudService != null) {
cloudService.hideBroadcastNotificationByReferenceId(referenceId);
}
}
/**
* Hides notifications that are associated with a tag to all mobile devices of a single user.
*
* @param userId the cloud user id of the recipient
* @param tag the tag associated with notifications
*
*/
@ActionDoc(text = "Hides notifications that are associated with a tag on mobile devices of user with userId")
public static void hideNotificationByTag(String userId, String tag) {
if (cloudService != null) {
cloudService.hideNotificationByTag(userId, tag);
}
}
/**
* Hides notifications that are associated with a tag to all mobile devices of all users of the account
*
* @param tag the tag associated with notifications
*
*/
@ActionDoc(text = "Hides notifications that are associated with a tag on all mobile devices of all account users")
public static void hideBroadcastNotificationByTag(String tag) {
if (cloudService != null) {
cloudService.hideBroadcastNotificationByTag(tag);
}
}
}

View File

@ -588,18 +588,20 @@ public class CloudClient {
* @param userId openHAB Cloud user id
* @param message notification message text
* @param icon name of the icon for this notification
* @param severity severity name for this notification
* @param tag name for this notification (formerly severity)
* @param title for the notification
* @param referenceId an identifier used to collapse and hide notifications
* @param onClickAction the action to perform when clicked
* @param mediaAttachmentUrl the media to attach to a notification
* @param actionButton1 an action button in the format "Title=Action"
* @param actionButton2 an action button in the format "Title=Action"
* @param actionButton3 an action button in the format "Title=Action"
*/
public void sendNotification(String userId, String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
sendNotificationInternal(userId, message, icon, severity, title, onClickAction, mediaAttachmentUrl,
public void sendNotification(String userId, String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
sendNotificationInternal(userId, message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
}
@ -608,23 +610,25 @@ public class CloudClient {
*
* @param message notification message text
* @param icon name of the icon for this notification
* @param severity severity name for this notification
* @param tag name for this notification (formerly severity)
* @param title for this notification
* @param referenceId an identifier used to collapse and hide notifications
* @param onClickAction the action to perform when clicked
* @param mediaAttachmentUrl the media to attach to a notification
* @param actionButton1 an action button in the format "Title=Action"
* @param actionButton2 an action button in the format "Title=Action"
* @param actionButton3 an action button in the format "Title=Action"
*/
public void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
sendNotificationInternal(null, message, icon, severity, title, onClickAction, mediaAttachmentUrl, actionButton1,
actionButton2, actionButton3);
public void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
sendNotificationInternal(null, message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
}
private void sendNotificationInternal(@Nullable String userId, String message, @Nullable String icon,
@Nullable String severity, @Nullable String title, @Nullable String onClickAction,
@Nullable String tag, @Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
if (isConnected()) {
@ -633,9 +637,19 @@ public class CloudClient {
if (userId != null) {
notificationMessage.put("userId", userId);
}
notificationMessage.put("type", "notification");
notificationMessage.put("message", message);
notificationMessage.put("icon", icon);
notificationMessage.put("severity", severity);
if (icon != null) {
notificationMessage.put("icon", icon);
}
if (tag != null) {
notificationMessage.put("tag", tag);
}
if (referenceId != null) {
notificationMessage.put("reference-id", referenceId);
}
if (title != null) {
notificationMessage.put("title", title);
}
@ -681,6 +695,68 @@ public class CloudClient {
}
}
/**
* This method hides a notification by its reference id for a single user
*
* @param userId openHAB Cloud user id
* @param referenceId the reference id
*/
public void hideNotificationByReferenceId(String userId, String referenceId) {
hideNotificationInternal(userId, referenceId, null);
}
/**
* This method hides a notification by its reference id for all users
*
* @param referenceId the reference id
*/
public void hideBroadcastNotificationByReferenceId(String referenceId) {
hideNotificationInternal(null, referenceId, null);
}
/**
* This method hides a notification by its tag for all users
*
* @param userId openHAB Cloud user id
* @param tag severity name for this notification
*/
public void hideNotificationByTag(String userId, String tag) {
hideNotificationInternal(userId, null, tag);
}
/**
* This method hides a notification by its tag for all users
*
* @param tag name for this notification
*/
public void hideBroadcastNotificationByTag(String tag) {
hideNotificationInternal(null, null, tag);
}
private void hideNotificationInternal(@Nullable String userId, @Nullable String referenceId, @Nullable String tag) {
if (isConnected()) {
JSONObject notificationMessage = new JSONObject();
try {
notificationMessage.put("type", "hideNotification");
if (userId != null) {
notificationMessage.put("userId", userId);
}
if (referenceId != null) {
notificationMessage.put("reference-id", referenceId);
}
if (tag != null) {
notificationMessage.put("tag", tag);
}
socket.emit(userId == null ? "broadcastnotification" : "notification", notificationMessage);
} catch (JSONException e) {
logger.debug("{}", e.getMessage());
}
} else {
logger.debug("No connection, notification is not sent");
}
}
/**
* Send item update to openHAB Cloud
*

View File

@ -114,19 +114,21 @@ public class CloudService implements ActionService, CloudClientListener, EventSu
* @param userId the {@link String} containing the openHAB Cloud user id to send message to
* @param message the {@link String} containing a message to send to specified user id
* @param icon the {@link String} containing a name of the icon to be used with this notification
* @param severity the {@link String} containing severity (good, info, warning, error) of notification
* @param tag the {@link String} containing tag of notification (formerly severity)
* @param title the {@link String} containing the title to be used with this notification
* @param referenceId the {@link String} identifier used to collapse and hide notifications
* @param onClickAction the {@link String} containing the action to perform when clicked
* @param mediaAttachmentUrl the {@link String} containing the media to attach to a notification
* @param actionButton1 the {@link String} containing the action button in the format "Title=Action"
* @param actionButton2 the {@link String} containing the action button in the format "Title=Action"
* @param actionButton3 the {@link String} containing the action button in the format "Title=Action"
*/
public void sendNotification(String userId, String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
public void sendNotification(String userId, String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
logger.debug("Sending message '{}' to user id {}", message, userId);
cloudClient.sendNotification(userId, message, icon, severity, title, onClickAction, mediaAttachmentUrl,
cloudClient.sendNotification(userId, message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
}
@ -149,22 +151,72 @@ public class CloudService implements ActionService, CloudClientListener, EventSu
*
* @param message the {@link String} containing a message to send to specified user id
* @param icon the {@link String} containing a name of the icon to be used with this notification
* @param severity the {@link String} containing severity (good, info, warning, error) of notification
* @param tag the {@link String} containing tag of notification (formerly severity)
* @param title the {@link String} containing the title to be used with this notification
* @param referenceId the {@link String} identifier used to collapse and hide notifications
* @param onClickAction the {@link String} containing the action to perform when clicked
* @param mediaAttachmentUrl the {@link String} containing the media to attach to a notification
* @param actionButton1 the {@link String} containing the action button in the format "Title=Action"
* @param actionButton2 the {@link String} containing the action button in the format "Title=Action"
* @param actionButton3 the {@link String} containing the action button in the format "Title=Action"
*/
public void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String severity,
@Nullable String title, @Nullable String onClickAction, @Nullable String mediaAttachmentUrl,
@Nullable String actionButton1, @Nullable String actionButton2, @Nullable String actionButton3) {
public void sendBroadcastNotification(String message, @Nullable String icon, @Nullable String tag,
@Nullable String title, @Nullable String referenceId, @Nullable String onClickAction,
@Nullable String mediaAttachmentUrl, @Nullable String actionButton1, @Nullable String actionButton2,
@Nullable String actionButton3) {
logger.debug("Sending broadcast message '{}' to all users", message);
cloudClient.sendBroadcastNotification(message, icon, severity, title, onClickAction, mediaAttachmentUrl,
cloudClient.sendBroadcastNotification(message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
}
/**
* This method hides a notification by its tag through the openHAB Cloud service for a specific user
*
* @param userId the {@link String} containing the openHAB Cloud user id to hide messages for
* @param tag the {@link String} containing severity group of notification
*
*/
public void hideNotificationByTag(String userId, String tag) {
logger.debug("hiding with tag '{}' to user id {}", tag, userId);
cloudClient.hideNotificationByTag(userId, tag);
}
/**
* This method hides a notification by its tag through the openHAB Cloud service for all
* mobile devices of all users of the account
*
* @param severity the {@link String} containing severity (good, info, warning, error) of notification
*
*/
public void hideBroadcastNotificationByTag(String tag) {
logger.debug("hiding broadcast with tag '{}'", tag);
cloudClient.hideBroadcastNotificationByTag(tag);
}
/**
* This method hides a notification by its reference id through the openHAB Cloud service for a specific user
*
* @param userId the {@link String} containing the openHAB Cloud user id to hide messages for
* @param severity the {@link String} containing severity group of notification
*
*/
public void hideNotificationByReferenceId(String userId, String referenceId) {
logger.debug("hiding with referenceId '{}' to user id {}", referenceId, userId);
cloudClient.hideNotificationByReferenceId(userId, referenceId);
}
/**
* This method hides a notification by its reference id through the openHAB Cloud service for all
* mobile devices of all users of the account
*
* @param severity the {@link String} containing severity (good, info, warning, error) of notification
*
*/
public void hideBroadcastNotificationByReferenceId(String referenceId) {
logger.debug("hiding broadcast with referenceId '{}'", referenceId);
cloudClient.hideBroadcastNotificationByReferenceId(referenceId);
}
private String substringBefore(String str, String separator) {
int index = str.indexOf(separator);
return index == -1 ? str : str.substring(0, index);

View File

@ -0,0 +1,48 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud.internal.actions;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.handler.BaseActionModuleHandler;
import org.openhab.core.automation.handler.ModuleHandler;
import org.openhab.core.config.core.ConfigParser;
import org.openhab.io.openhabcloud.internal.CloudService;
/**
* This is a base {@link ModuleHandler} implementation for {@link Action}s to hide notifications via openHAB Cloud.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public abstract class BaseHideNotificationActionHandler extends BaseActionModuleHandler {
public static final String PARAM_TAG = "tag";
public static final String PARAM_REFERENCE_ID = "referenceId";
protected final CloudService cloudService;
protected final @Nullable String tag;
protected final @Nullable String referenceId;
public BaseHideNotificationActionHandler(Action module, CloudService cloudService) {
super(module);
this.cloudService = cloudService;
this.tag = stringConfig(PARAM_TAG);
this.referenceId = stringConfig(PARAM_REFERENCE_ID);
}
protected @Nullable String stringConfig(String key) {
return ConfigParser.valueAs(module.getConfiguration().get(key), String.class);
}
}

View File

@ -12,6 +12,8 @@
*/
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
@ -32,7 +34,9 @@ public abstract class BaseNotificationActionHandler extends BaseActionModuleHand
public static final String PARAM_MESSAGE = "message";
public static final String PARAM_ICON = "icon";
public static final String PARAM_SEVERITY = "severity";
public static final String PARAM_TAG = "tag";
public static final String PARAM_TITLE = "title";
public static final String PARAM_REFERENCE_ID = "referenceId";
public static final String PARAM_ON_CLICK_ACTION = "onClickAction";
public static final String PARAM_MEDIA_ATTACHMENT_URL = "mediaAttachmentUrl";
public static final String PARAM_ACTION_BUTTON_1 = "actionButton1";
@ -44,7 +48,9 @@ public abstract class BaseNotificationActionHandler extends BaseActionModuleHand
protected final String message;
protected final @Nullable String icon;
protected final @Nullable String severity;
protected final @Nullable String tag;
protected final @Nullable String title;
protected final @Nullable String referenceId;
protected final @Nullable String onClickAction;
protected final @Nullable String mediaAttachmentUrl;
protected final @Nullable String actionButton1;
@ -55,16 +61,13 @@ public abstract class BaseNotificationActionHandler extends BaseActionModuleHand
super(module);
this.cloudService = cloudService;
Object messageParam = module.getConfiguration().get(PARAM_MESSAGE);
if (messageParam instanceof String) {
this.message = messageParam.toString();
} else {
throw new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_MESSAGE));
}
this.message = Optional.ofNullable(stringConfig(PARAM_MESSAGE)).orElseThrow(() -> new IllegalArgumentException(
String.format("Param '%s' should be of type String.", PARAM_MESSAGE)));
this.icon = stringConfig(PARAM_ICON);
this.severity = stringConfig(PARAM_SEVERITY);
this.tag = stringConfig(PARAM_TAG);
this.title = stringConfig(PARAM_TITLE);
this.referenceId = stringConfig(PARAM_REFERENCE_ID);
this.onClickAction = stringConfig(PARAM_ON_CLICK_ACTION);
this.mediaAttachmentUrl = stringConfig(PARAM_MEDIA_ATTACHMENT_URL);
this.actionButton1 = stringConfig(PARAM_ACTION_BUTTON_1);
@ -72,7 +75,7 @@ public abstract class BaseNotificationActionHandler extends BaseActionModuleHand
this.actionButton3 = stringConfig(PARAM_ACTION_BUTTON_3);
}
private @Nullable String stringConfig(String key) {
protected @Nullable String stringConfig(String key) {
return ConfigParser.valueAs(module.getConfiguration().get(key), String.class);
}
}

View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.handler.ModuleHandler;
import org.openhab.io.openhabcloud.internal.CloudService;
/**
* This is a {@link ModuleHandler} implementation for {@link Action}s to hide a notification to a specific cloud user.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class HideBroadcastNotificationByReferenceIdActionHandler extends BaseHideNotificationActionHandler {
public static final String TYPE_ID = "notification.HideBroadcastNotificationByReferenceId";
public HideBroadcastNotificationByReferenceIdActionHandler(Action module, CloudService cloudService) {
super(module, cloudService);
}
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.hideBroadcastNotificationByReferenceId(referenceId);
return null;
}
}

View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.handler.ModuleHandler;
import org.openhab.io.openhabcloud.internal.CloudService;
/**
* This is a {@link ModuleHandler} implementation for {@link Action}s to hide a notification to a specific cloud user.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class HideBroadcastNotificationByTagActionHandler extends BaseHideNotificationActionHandler {
public static final String TYPE_ID = "notification.HideBroadcastNotificationByTag";
public HideBroadcastNotificationByTagActionHandler(Action module, CloudService cloudService) {
super(module, cloudService);
}
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.hideBroadcastNotificationByTag(tag);
return null;
}
}

View File

@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.handler.ModuleHandler;
import org.openhab.io.openhabcloud.internal.CloudService;
/**
* This is a {@link ModuleHandler} implementation for {@link Action}s to hide a notification to a specific cloud user.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class HideNotificationByReferenceIdActionHandler extends BaseHideNotificationActionHandler {
public static final String TYPE_ID = "notification.HideNotificationByReferenceId";
public static final String PARAM_USER = "userId";
private final String userId;
public HideNotificationByReferenceIdActionHandler(Action module, CloudService cloudService) {
super(module, cloudService);
this.userId = Optional.ofNullable(stringConfig(PARAM_USER)).orElseThrow(
() -> new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_USER)));
}
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.hideNotificationByReferenceId(userId, referenceId);
return null;
}
}

View File

@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.handler.ModuleHandler;
import org.openhab.io.openhabcloud.internal.CloudService;
/**
* This is a {@link ModuleHandler} implementation for {@link Action}s to hide a notification to a specific cloud user.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class HideNotificationByTagActionHandler extends BaseHideNotificationActionHandler {
public static final String TYPE_ID = "notification.HideNotificationByTag";
public static final String PARAM_USER = "userId";
private final String userId;
public HideNotificationByTagActionHandler(Action module, CloudService cloudService) {
super(module, cloudService);
this.userId = Optional.ofNullable(stringConfig(PARAM_USER)).orElseThrow(
() -> new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_USER)));
}
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.hideNotificationByTag(userId, tag);
return null;
}
}

View File

@ -46,14 +46,14 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
private static final ModuleType SEND_EXTENDED_NOTIFICATION_ACTION = new ActionType(
SendNotificationActionHandler.EXTENDED_TYPE_ID, getNotificationConfig(ConfigType.EXTENDED, true, null),
"send a notification with icon and severity",
"Sends a notification to a specific cloud user. Optionally add an icon or the severity.", null,
"send a notification with icon and severity (tag)",
"Sends a notification to a specific cloud user. Optionally add an icon or the severity (tag).", null,
Visibility.VISIBLE, null, null);
private static final ModuleType SEND_EXTENDED2_NOTIFICATION_ACTION = new ActionType(
SendNotificationActionHandler.EXTENDED2_TYPE_ID, getNotificationConfig(ConfigType.EXTENDED2, true, null),
"send a notification with icon, severity, title, click action, media attachment and action buttons",
"Sends a notification to a specific cloud user. Optionally add an icon, severity, title, on click action, media to attach, and up to 3 action buttons with a format of \"Title=Action\".",
"send a notification with icon, tag, title, reference id, click action, media attachment and action buttons",
"Sends a notification to a specific cloud user. Optionally add an icon, tag, title, reference id, on click action, media to attach, and up to 3 action buttons with a format of \"Title=Action\".",
null, Visibility.VISIBLE, null, null);
private static final ModuleType SEND_BROADCAST_NOTIFICATION_ACTION = new ActionType(
@ -63,15 +63,16 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
private static final ModuleType SEND_EXTENDED_BROADCAST_NOTIFICATION_ACTION = new ActionType(
SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID,
getNotificationConfig(ConfigType.EXTENDED, false, null), "broadcast a notification with icon and severity",
"Sends a notification to all devices of all users. Optionally add an icon or the severity.", null,
getNotificationConfig(ConfigType.EXTENDED, false, null),
"broadcast a notification with icon and severity (tag)",
"Sends a notification to all devices of all users. Optionally add an icon or the severity (tag).", null,
Visibility.VISIBLE, null, null);
private static final ModuleType SEND_EXTENDED2_BROADCAST_NOTIFICATION_ACTION = new ActionType(
SendBroadcastNotificationActionHandler.EXTENDED2_TYPE_ID,
getNotificationConfig(ConfigType.EXTENDED2, false, null),
"broadcast a notification with with icon, severity, title, on click action, media attachment and action buttons",
"Sends a notification to all devices of all users. Optionally add an icon, severity, title, click action, media to attach, and up to 3 action buttons with a format of \"Title=Action\".",
"broadcast a notification with with icon, tag, title, reference id, on click action, media attachment and action buttons",
"Sends a notification to all devices of all users. Optionally add an icon, tag, title, reference id, click action, media to attach, and up to 3 action buttons with a format of \"Title=Action\".",
null, Visibility.VISIBLE, null, null);
private static final ModuleType SEND_LOG_NOTIFICATION_ACTION = new ActionType(
@ -82,14 +83,40 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
private static final ModuleType SEND_EXTENDED_LOG_NOTIFICATION_ACTION = new ActionType(
SendLogNotificationActionHandler.EXTENDED_TYPE_ID, getNotificationConfig(ConfigType.EXTENDED, false, null),
"send a log message with icon and severity",
"Sends a log notification to the openHAB Cloud instance. Optionally add an icon or the severity. Notifications are NOT sent to any registered devices.",
"send a log message with icon and severity (tag)",
"Sends a log notification to the openHAB Cloud instance. Optionally add an icon or the severity (tag). Notifications are NOT sent to any registered devices.",
null, Visibility.VISIBLE, null, null);
private static final ModuleType HIDE_NOTIFICATION_BY_REFERENCE_ID_ACTION = new ActionType(
HideNotificationByReferenceIdActionHandler.TYPE_ID,
getNotificationConfig(ConfigType.HIDE_BY_REF, true, null),
"hide notifications by reference id for all devices of a specific user",
"Hide notifications by reference id for all devices of a specific user.", null, Visibility.VISIBLE, null,
null);
private static final ModuleType HIDE_BROADCAST_NOTIFICATION_BY_REFERENCE_ID_ACTION = new ActionType(
HideBroadcastNotificationByReferenceIdActionHandler.TYPE_ID,
getNotificationConfig(ConfigType.HIDE_BY_REF, false, null),
"hide notifications by reference id for all users and devices",
"Hide notifications by reference id for all users and devices.", null, Visibility.VISIBLE, null, null);
private static final ModuleType HIDE_NOTIFICATION_BY_TAG_ACTION = new ActionType(
HideNotificationByTagActionHandler.TYPE_ID, getNotificationConfig(ConfigType.HIDE_BY_TAG, true, null),
"hide notifications by tag for all devices of a specific user",
"Hide notifications by tag id for all devices of a specific user.", null, Visibility.VISIBLE, null, null);
private static final ModuleType HIDE_BROADCAST_NOTIFICATION_BY_TAG_ACTION = new ActionType(
HideBroadcastNotificationByTagActionHandler.TYPE_ID,
getNotificationConfig(ConfigType.HIDE_BY_TAG, false, null),
"hide notifications by tag id for all users and devices",
"Hide notifications by tag id for all users and devices.", null, Visibility.VISIBLE, null, null);
private static final List<ModuleType> MODULE_TYPES = List.of(SEND_NOTIFICATION_ACTION,
SEND_EXTENDED_NOTIFICATION_ACTION, SEND_EXTENDED2_NOTIFICATION_ACTION, SEND_BROADCAST_NOTIFICATION_ACTION,
SEND_EXTENDED_BROADCAST_NOTIFICATION_ACTION, SEND_EXTENDED2_BROADCAST_NOTIFICATION_ACTION,
SEND_LOG_NOTIFICATION_ACTION, SEND_EXTENDED_LOG_NOTIFICATION_ACTION);
SEND_LOG_NOTIFICATION_ACTION, SEND_EXTENDED_LOG_NOTIFICATION_ACTION,
HIDE_BROADCAST_NOTIFICATION_BY_REFERENCE_ID_ACTION, HIDE_BROADCAST_NOTIFICATION_BY_TAG_ACTION,
HIDE_NOTIFICATION_BY_REFERENCE_ID_ACTION, HIDE_NOTIFICATION_BY_TAG_ACTION);
@SuppressWarnings("unchecked")
@Override
@ -111,6 +138,14 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
return SEND_LOG_NOTIFICATION_ACTION;
case SendLogNotificationActionHandler.EXTENDED_TYPE_ID:
return SEND_EXTENDED_LOG_NOTIFICATION_ACTION;
case HideNotificationByTagActionHandler.TYPE_ID:
return HIDE_NOTIFICATION_BY_TAG_ACTION;
case HideBroadcastNotificationByTagActionHandler.TYPE_ID:
return HIDE_BROADCAST_NOTIFICATION_BY_TAG_ACTION;
case HideNotificationByReferenceIdActionHandler.TYPE_ID:
return HIDE_NOTIFICATION_BY_REFERENCE_ID_ACTION;
case HideBroadcastNotificationByReferenceIdActionHandler.TYPE_ID:
return HIDE_BROADCAST_NOTIFICATION_BY_REFERENCE_ID_ACTION;
default:
return null;
}
@ -135,21 +170,33 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
.withRequired(true).withLabel("User Id").withDescription("The cloud user id of the recipient.")
.build());
}
if (type == ConfigType.EXTENDED || type == ConfigType.EXTENDED2) {
params.add(getMessageConfigParameter(locale));
params.add(getIconConfigParameter(locale));
params.add(getSeverityConfigParameter(locale));
switch (type) {
case EXTENDED:
params.add(getMessageConfigParameter(locale));
params.add(getIconConfigParameter(locale));
params.add(getSeverityConfigParameter(locale));
break;
case EXTENDED2:
params.add(getMessageConfigParameter(locale));
params.add(getIconConfigParameter(locale));
params.add(getTagConfigParameter(locale));
params.add(getTitleConfigParameter(locale));
params.add(getReferenceIdConfigParameter(locale));
params.add(getonClickActionConfigParameter(locale));
params.add(getMediaAttachmentUrlConfigParameter(locale));
params.add(getActionButton1ConfigParameter(locale));
params.add(getActionButton2ConfigParameter(locale));
params.add(getActionButton3ConfigParameter(locale));
break;
case HIDE_BY_TAG:
params.add(getTagConfigParameter(locale));
break;
case HIDE_BY_REF:
params.add(getReferenceIdConfigParameter(locale));
break;
default:
break;
}
if (type == ConfigType.EXTENDED2) {
params.add(getTitleConfigParameter(locale));
params.add(getonClickActionConfigParameter(locale));
params.add(getMediaAttachmentUrlConfigParameter(locale));
params.add(getActionButton1ConfigParameter(locale));
params.add(getActionButton2ConfigParameter(locale));
params.add(getActionButton3ConfigParameter(locale));
}
return params;
}
@ -165,7 +212,12 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
private static ConfigDescriptionParameter getSeverityConfigParameter(@Nullable Locale locale) {
return ConfigDescriptionParameterBuilder.create(BaseNotificationActionHandler.PARAM_SEVERITY, Type.TEXT)
.withLabel("Severity").withDescription("The severity of the notification.").build();
.withLabel("Severity (Tag)").withDescription("The severity/tag of the notification.").build();
}
private static ConfigDescriptionParameter getTagConfigParameter(@Nullable Locale locale) {
return ConfigDescriptionParameterBuilder.create(BaseNotificationActionHandler.PARAM_TAG, Type.TEXT)
.withLabel("Tag").withDescription("The tag of the notification.").build();
}
private static ConfigDescriptionParameter getTitleConfigParameter(@Nullable Locale locale) {
@ -173,6 +225,11 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
.withLabel("Title").withDescription("The title of the notification.").build();
}
private static ConfigDescriptionParameter getReferenceIdConfigParameter(@Nullable Locale locale) {
return ConfigDescriptionParameterBuilder.create(BaseNotificationActionHandler.PARAM_REFERENCE_ID, Type.TEXT)
.withLabel("Reference Id").withDescription("A reference Id for the notification.").build();
}
private static ConfigDescriptionParameter getonClickActionConfigParameter(@Nullable Locale locale) {
return ConfigDescriptionParameterBuilder.create(BaseNotificationActionHandler.PARAM_ON_CLICK_ACTION, Type.TEXT)
.withLabel("On Click Action").withDescription("The action to perform when clicked.").build();
@ -215,6 +272,8 @@ public class NotificationActionTypeProvider implements ModuleTypeProvider {
private enum ConfigType {
NOT_EXTENDED,
EXTENDED,
EXTENDED2;
EXTENDED2,
HIDE_BY_TAG,
HIDE_BY_REF;
}
}

View File

@ -43,7 +43,10 @@ public class NotificationModuleHandlerFactory extends BaseModuleHandlerFactory {
SendNotificationActionHandler.EXTENDED_TYPE_ID, SendNotificationActionHandler.EXTENDED2_TYPE_ID,
SendBroadcastNotificationActionHandler.TYPE_ID, SendBroadcastNotificationActionHandler.EXTENDED_TYPE_ID,
SendBroadcastNotificationActionHandler.EXTENDED2_TYPE_ID, SendLogNotificationActionHandler.TYPE_ID,
SendLogNotificationActionHandler.EXTENDED_TYPE_ID);
SendLogNotificationActionHandler.EXTENDED_TYPE_ID,
HideBroadcastNotificationByReferenceIdActionHandler.TYPE_ID,
HideBroadcastNotificationByTagActionHandler.TYPE_ID, HideNotificationByReferenceIdActionHandler.TYPE_ID,
HideNotificationByTagActionHandler.TYPE_ID);
private final CloudService cloudService;
@Activate
@ -77,6 +80,14 @@ public class NotificationModuleHandlerFactory extends BaseModuleHandlerFactory {
case SendLogNotificationActionHandler.TYPE_ID:
case SendLogNotificationActionHandler.EXTENDED_TYPE_ID:
return new SendLogNotificationActionHandler(action, cloudService);
case HideBroadcastNotificationByReferenceIdActionHandler.TYPE_ID:
return new HideBroadcastNotificationByReferenceIdActionHandler(action, cloudService);
case HideNotificationByReferenceIdActionHandler.TYPE_ID:
return new HideNotificationByReferenceIdActionHandler(action, cloudService);
case HideBroadcastNotificationByTagActionHandler.TYPE_ID:
return new HideBroadcastNotificationByTagActionHandler(action, cloudService);
case HideNotificationByTagActionHandler.TYPE_ID:
return new HideNotificationByTagActionHandler(action, cloudService);
default:
break;
}

View File

@ -40,8 +40,8 @@ public class SendBroadcastNotificationActionHandler extends BaseNotificationActi
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.sendBroadcastNotification(message, icon, severity, title, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
cloudService.sendBroadcastNotification(message, icon, tag == null ? severity : tag, title, referenceId,
onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3);
return null;
}
}

View File

@ -13,6 +13,7 @@
package org.openhab.io.openhabcloud.internal.actions;
import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@ -40,18 +41,14 @@ public class SendNotificationActionHandler extends BaseNotificationActionHandler
public SendNotificationActionHandler(Action module, CloudService cloudService) {
super(module, cloudService);
Object userIdParam = module.getConfiguration().get(PARAM_USER);
if (userIdParam instanceof String) {
this.userId = userIdParam.toString();
} else {
throw new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_USER));
}
this.userId = Optional.ofNullable(stringConfig(PARAM_USER)).orElseThrow(
() -> new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_USER)));
}
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
cloudService.sendNotification(userId, message, icon, severity, title, onClickAction, mediaAttachmentUrl,
actionButton1, actionButton2, actionButton3);
cloudService.sendNotification(userId, message, icon, tag == null ? severity : tag, title, referenceId,
onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3);
return null;
}
}