Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstallationService custom implementation #1111

Closed
joarobles opened this issue Jan 27, 2023 · 3 comments
Closed

InstallationService custom implementation #1111

joarobles opened this issue Jan 27, 2023 · 3 comments
Labels
project:bolt question M-T: User needs support to use the project

Comments

@joarobles
Copy link

I'm trying to implement InstallationService to persist installations using Spring JPA. I'm having problems with the find...() methods because it's not clear enough how the parameters order should be considered.

    /**
     * Returns a bot permission data if exists.
     */
    Bot findBot(String enterpriseId, String teamId);

    /**
     * Returns a user permission data if exists.
     */
    Installer findInstaller(String enterpriseId, String teamId, String userId);

Should I look for bots and installations with all the given parameters being present? All parameters are nullable? If that's the case, what should I do to handle them?

I've seen the code in FileInstallationService and AmazonS3InstallationService but it seems to be plenty of if conditions that I could not extrapolate to a rule.

@seratch seratch added question M-T: User needs support to use the project project:bolt and removed untriaged labels Jan 28, 2023
@seratch
Copy link
Member

seratch commented Jan 28, 2023

Hi @joarobles, thanks for asking the question!

Should I look for bots and installations with all the given parameters being present? All parameters are nullable? If that's the case, what should I do to handle them?

This depends on how your app installation flow looks like.

If your app requests only bot scopes, you don't need to save installer data and implement the findInstaller() method. So, implementing only bot-related methods is totally fine! but if you want to keep track of installation history with the installing users, having both can be useful for some purpose.

If your app receives both bot and user tokens, implementing both is recommended, but it's optional. If you have findInstaller() method, the context object may provide a relevant user token for a user associated with the event request.

If you're comfortable checking the framework code more, reading https://github.com/slackapi/java-slack-sdk/blob/v1.27.3/bolt/src/main/java/com/slack/api/bolt/middleware/builtin/MultiTeamsAuthorization.java is the best way to understand how InstallationService can be used in the Bolt framework.

I hope this was helpful to you!

@seratch
Copy link
Member

seratch commented Jan 28, 2023

Forgot to reply to the nullable or not topic. Checking Python SDK's this code can be the most helpful at this moment (you don't need to follow this exactly but checking this should be helpful). As you already notice (thanks for the comment!), RDB support is on our long-term roadmap: #347 Our SDK team will do its best to add the module as early as possible.

@joarobles
Copy link
Author

Thanks @seratch! I'll take a look at the links you provided, have a nice week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project:bolt question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants