joewitt commented on code in PR #9010:
URL: https://github.com/apache/nifi/pull/9010#discussion_r1662950720


##########
nifi-extension-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/GetSlackReaction.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.request.reactions.ReactionsGetRequest;
+import com.slack.api.methods.response.reactions.ReactionsGetResponse;
+import com.slack.api.model.Reaction;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.processors.slack.util.SlackResponseUtil;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@WritesAttributes({
+        @WritesAttribute(attribute = GetSlackReaction.ATTR_CHANNEL_ID, 
description = "The ID of the Slack Channel from which the messages were 
retrieved"),
+        @WritesAttribute(attribute = GetSlackReaction.ATTR_MESSAGE_TIMESTAMP, 
description = "The timestamp of the Slack message the reactions are fetched 
for."),
+        @WritesAttribute(attribute = "slack.reaction.<emoji name>", 
description = "The name of the emoji and the reaction count that was provided 
for the message."),
+        @WritesAttribute(attribute = GetSlackReaction.ATTR_WAIT_TIME, 
description = "The total number of minutes waited while the reactions were 
captured."),
+        @WritesAttribute(attribute = GetSlackReaction.ATTR_ERROR_MESSAGE, 
description = "The error message on fetching reactions.")
+})
+@SeeAlso({ListenSlack.class, ConsumeSlack.class, PublishSlack.class})
+@Tags({"slack", "conversation", "reactions.get", "social media", "emoji"})
+@CapabilityDescription("Retrieves reactions for a given message. The reactions 
are written as attributes.")
+@DefaultSettings(penaltyDuration = "5 min")
+public class GetSlackReaction extends AbstractProcessor {
+    public static final String ATTR_WAIT_TIME = "minutes.waited";
+    public static final String ATTR_ERROR_MESSAGE = "error.message";
+    public static final String ATTR_MESSAGE_TIMESTAMP = 
"slack.message.timestamp";
+    public static final String ATTR_CHANNEL_ID = "slack.channel.id";
+    public static final int PENALTY_MINUTES = 5;
+
+    static final PropertyDescriptor ACCESS_TOKEN = new 
PropertyDescriptor.Builder()
+            .name("Access Token")
+            .description("OAuth Access Token used for 
authenticating/authorizing the Slack request sent by NiFi. This may be either a 
User Token or a Bot Token. " +
+                    "It must be granted the reactions:read scope and 
channels:history, groups:history, im:history or mpim:history, depending on the 
type of conversation being used.")
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .required(true)
+            .sensitive(true)
+            .build();
+
+    static final PropertyDescriptor CHANNEL_ID = new 
PropertyDescriptor.Builder()
+            .name("Channel ID")
+            .description("The ID of the channel.")
+            .required(true)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+            .build();
+
+    static final PropertyDescriptor THREAD_TIMESTAMP = new 
PropertyDescriptor.Builder()
+            .name("Message Timestamp")
+            .description("Slack message's timestamp the reactions are fetched 
for.")
+            .required(true)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+            .build();
+
+    static final PropertyDescriptor RELEASE_IF_ONE_REACTION = new 
PropertyDescriptor.Builder()

Review Comment:
   It is clear.  I still think 'release_per_reaction' makes more sense as to 
what the user means.  Basically what we mean to say is "Release as soon as we 
get any reaction" but that sounds too long.  
   
   overall though I'm hesitant to be in code review mode based on the initial 
description and pr. You might want to consider starting with a more descriptive 
JIRA and then a PR that aligns to it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to