eschutho commented on code in PR #29264:
URL: https://github.com/apache/superset/pull/29264#discussion_r1680023630


##########
superset/utils/slack.py:
##########
@@ -31,6 +46,81 @@ def get_slack_client() -> WebClient:
     return WebClient(token=token, proxy=current_app.config["SLACK_PROXY"])
 
 
+def get_channels_with_search(
+    search_string: str = "",
+    limit: int = 999,
+    types: Optional[list[SlackChannelTypes]] = None,
+    exact_match: bool = False,
+) -> list[str]:
+    """
+    The slack api is paginated but does not include search, so we need to fetch
+    all channels and filter them ourselves
+    This will search by slack name or id
+    """
+
+    try:
+        client = get_slack_client()
+        channels = []
+        cursor = None
+        extra_params = {}
+        extra_params["types"] = ",".join(types) if types else None
+
+        while True:
+            response = client.conversations_list(
+                limit=limit, cursor=cursor, exclude_archived=True, 
**extra_params
+            )
+            channels.extend(response.data["channels"])
+            cursor = response.data.get("response_metadata", 
{}).get("next_cursor")
+            if not cursor:
+                break
+
+        # The search string can be multiple channels separated by commas
+        if search_string:
+            search_array = [
+                search.lower()
+                for search in (search_string.split(",") if search_string else 
[])
+            ]
+            print(channels)

Review Comment:
   Thanks for catching!



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to