Skip to content

Fix #976 Add deletion methods to InstallationStore - #995

Merged
seratch merged 1 commit into
slackapi:mainfrom
seratch:issue-976-deletion
Apr 9, 2021
Merged

seratch merged 1 commit into
slackapi:mainfrom
seratch:issue-976-deletion

Conversation

@seratch

@seratch seratch commented Apr 9, 2021

Copy link
Copy Markdown
Contributor

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
@codecov

codecov Bot commented Apr 9, 2021

Copy link
Copy Markdown

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.

@stevengill stevengill left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks Great @seratch!!

@seratch

seratch commented Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

@stevengill Thanks for checking this!

@seratch
seratch merged commit e82c29b into slackapi:main Apr 9, 2021
@seratch
seratch deleted the issue-976-deletion branch April 9, 2021 23:39
@seratch seratch mentioned this pull request Apr 10, 2021
3 tasks done
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