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

Fix #976 Add deletion methods to InstallationStore #995

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

seratch
Copy link
Member

@seratch seratch commented Apr 9, 2021

Summary

This pull request resolves #976 . Refer to the issue for details. A Bolt app that utilizes these methods would be like this:

app = App(
    signing_secret=os.environ["SLACK_SIGNING_SECRET"],
    oauth_settings=OAuthSettings(
        client_id=os.environ["SLACK_CLIENT_ID"],
        client_secret=os.environ["SLACK_CLIENT_SECRET"],
        scopes=["commands", "chat:write", "app_mentions:read"],
        user_scopes=["search:read"],
        installation_store=installation_store,
        state_store=oauth_state_store,
    ),
)

@app.event("app_mention")
def app_mentions(event, logger, say):
    logger.info(event)
    say("Hi!")

@app.event("tokens_revoked")
def revoke_tokens(event: dict, context: BoltContext):
    user_ids = event.get("tokens", {}).get("oauth", [])
    for user_id in user_ids:
        installation_store.delete_installation(
            enterprise_id=context.enterprise_id,
            team_id=context.team_id,
            user_id=user_id,
        )
    if len(event.get("tokens", {}).get("bot", [])) > 0:
        installation_store.delete_bot(
            enterprise_id=context.enterprise_id,
            team_id=context.team_id,
        )

@app.event("app_uninstalled")
def uninstall(context: BoltContext):
    installation_store.delete_all(
        enterprise_id=context.enterprise_id,
        team_id=context.team_id,
    )

if __name__ == "__main__":
    app.start(port=3000)

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

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.models (UI component builders)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.rtm (RTM client)
  • slack_sdk.signature (Request Signature Verifier)
  • /docs-src (Documents, have you run ./docs.sh?)
  • /docs-src-v2 (Documents, have you run ./docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • 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 python setup.py validate after making the changes.

@seratch seratch added enhancement M-T: A feature request for new functionality Version: 3x oauth labels Apr 9, 2021
@seratch seratch added this to the 3.5.0 milestone Apr 9, 2021
@seratch seratch requested review from mwbrooks and stevengill April 9, 2021 13:04
@seratch seratch self-assigned this Apr 9, 2021
@seratch seratch force-pushed the issue-976-deletion branch from 06a0878 to 0becbc9 Compare April 9, 2021 13:15
@codecov
Copy link

codecov bot commented Apr 9, 2021

Codecov Report

Merging #995 (0becbc9) into main (a878264) will decrease coverage by 0.69%.
The diff coverage is 44.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
- Coverage   87.27%   86.57%   -0.70%     
==========================================
  Files          94       94              
  Lines        8605     8747     +142     
==========================================
+ Hits         7510     7573      +63     
- Misses       1095     1174      +79     
Impacted Files Coverage Δ
...sdk/oauth/installation_store/amazon_s3/__init__.py 0.00% <0.00%> (ø)
...lation_store/async_cacheable_installation_store.py 53.70% <21.05%> (-16.57%) ⬇️
...installation_store/cacheable_installation_store.py 53.70% <21.05%> (-16.57%) ⬇️
...uth/installation_store/async_installation_store.py 61.90% <42.85%> (-9.53%) ⬇️
...k_sdk/oauth/installation_store/sqlite3/__init__.py 88.39% <66.66%> (-4.17%) ⬇️
...sdk/oauth/installation_store/installation_store.py 71.42% <71.42%> (ø)
...lack_sdk/oauth/installation_store/file/__init__.py 86.29% <81.48%> (-1.34%) ⬇️
...dk/oauth/installation_store/sqlalchemy/__init__.py 97.53% <100.00%> (+0.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a878264...0becbc9. Read the comment docs.

Copy link
Member

@stevengill stevengill left a comment

Choose a reason for hiding this comment

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

Looks Great @seratch!!

@seratch
Copy link
Member Author

seratch commented Apr 9, 2021

@stevengill Thanks for checking this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality oauth Version: 3x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add deletion methods to InstallationStore
2 participants