Skip to content

Conversation

@WilliamBergamin
Copy link
Contributor

moving changes to future branch

(Describe the goal of this PR. Mention any related Issue numbers)

Category (place an x in each of the [ ])

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements (place an x in each [ ])

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

moving changes to future branch
@seratch seratch added the enhancement New feature or request label Aug 26, 2022
@seratch seratch added this to the 1.x milestone Aug 26, 2022
return self.get("authorize_result")

@property
def bot_access_token(self) -> Optional[str]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this? This is duplicated with bot_token


def __init__(
self,
_register_listener: Callable[..., Optional[Callable[..., Optional[BoltResponse]]]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move the private function in App and use it here too. Let's remove this argument. This interface is not easy to use for developers.

def __init__(
self,
_register_listener: Callable[..., Optional[Callable[..., Optional[BoltResponse]]]],
_base_logger: Logger,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using _ (underscore) prefix for arg names is not generally recommended. base_logger or logger would be fine



def extract_bot_access_token(payload: Dict[str, Any]) -> Optional[str]:
if payload.get("bot_access_token") is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can merge this logic to the part extracting bot_token

function_execution_id = extract_function_execution_id(body)
if function_execution_id:
context["function_execution_id"] = function_execution_id
bot_access_token = extract_bot_access_token(body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this part

if self._token is not None:
# This WebClient instance can be safely singleton
req.context["client"] = self._client
req.context["client"] = create_copy(self._client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the singleton client does not work for next-gen functions, you can simplify this part. The extra overhead by this change should be ignorable.

    def _init_context(self, req: BoltRequest):
        req.context["logger"] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
        req.context["token"] = self._token
        client_per_request: WebClient = WebClient(
            token=self._token,  # this can be None
            base_url=self._client.base_url,
            timeout=self._client.timeout,
            ssl=self._client.ssl,
            proxy=self._client.proxy,
            headers=self._client.headers,
            team_id=req.context.team_id,
        )
        req.context["client"] = client_per_request

@WilliamBergamin
Copy link
Contributor Author

@seratch Thank you for the feedback 💯 I will add these changes to my branch 🥇

Since this feature still needs a lot of work I will close the PR and reopen it when more work is done

@seratch seratch changed the title Future function interactivity (#1) WIP: Future function interactivity Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants