You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "tenthe (via GitHub)" <gi...@apache.org> on 2023/12/12 09:57:28 UTC
Re: [PR] Extend all MS Teams sink by a silent period
tenthe commented on code in PR #2311:
URL: https://github.com/apache/streampipes/pull/2311#discussion_r1423749781
##########
streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/notification/InternalStreamPipesNotificationSink.java:
##########
@@ -61,63 +53,59 @@ public class NotificationProducer extends StreamPipesDataSink {
@Override
public void onInvocation(SinkParams parameters, EventSinkRuntimeContext context) throws
- SpRuntimeException {
- this.title = parameters.extractor().singleValueParameter(TITLE_KEY, String.class);
- this.content = parameters.extractor().singleValueParameter(CONTENT_KEY, String.class);
- this.silentPeriodInSeconds = parameters.extractor().singleValueParameter(SILENT_PERIOD, Integer.class) * 60;
- this.correspondingPipelineId = parameters.getModel().getCorrespondingPipeline();
- this.correspondingUser = parameters.getModel().getCorrespondingUser();
+ SpRuntimeException {
+ super.onInvocation(parameters, context);
+ this.title = parameters.extractor()
+ .singleValueParameter(TITLE_KEY, String.class);
+ this.content = parameters.extractor()
+ .singleValueParameter(CONTENT_KEY, String.class);
+ this.correspondingPipelineId = parameters.getModel()
+ .getCorrespondingPipeline();
+ this.correspondingUser = parameters.getModel()
+ .getCorrespondingUser();
this.client = context.getStreamPipesClient();
}
@Override
- public void onEvent(Event inputEvent) {
- if (shouldSendNotification()) {
- Date currentDate = new Date();
- Notification notification = new Notification();
- notification.setId(UUID.randomUUID().toString());
- notification.setRead(false);
- notification.setTitle(title);
- notification.setMessage(PlaceholderExtractor.replacePlaceholders(inputEvent, content));
- notification.setCreatedAt(currentDate);
- notification.setCreatedAtTimestamp(currentDate.getTime());
- notification.setCorrespondingPipelineId(correspondingPipelineId);
- notification.setTargetedAt(correspondingUser);
-
- // TODO add targeted user to notification object
-
- client.notificationsApi().add(notification);
- this.lastMessageEpochSecond = Instant.now().getEpochSecond();
- }
+ public void onNotificationEvent(Event inputEvent) {
+
+ Date currentDate = new Date();
+ Notification notification = new Notification();
+ notification.setId(UUID.randomUUID()
+ .toString());
+ notification.setRead(false);
+ notification.setTitle(title);
+ notification.setMessage(PlaceholderExtractor.replacePlaceholders(inputEvent, content));
+ notification.setCreatedAt(currentDate);
+ notification.setCreatedAtTimestamp(currentDate.getTime());
+ notification.setCorrespondingPipelineId(correspondingPipelineId);
+ notification.setTargetedAt(correspondingUser);
+
+ // TODO add targeted user to notification object
Review Comment:
Can we remove this and create an issue for this feature instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org