slackapi / bolt-js

A framework to build Slack apps using JavaScript
https://slack.dev/bolt-js
MIT License
2.73k stars 390 forks source link

Automatically invoke the InstallationStore's deleteInstallation function for relevant events #1203

Open misscoded opened 2 years ago

misscoded commented 2 years ago

Description

Currently, deleteInstallation of a developer-provided InstallationStore must be invoked manually. It would be more intuitive behavior to have it invoked automatically when the app_uninstalled and token_revoked events are received.

Aside from a couple of community members raising questions around this (#1201, #1112), it's my understanding that the Java and Python implementations already support this.

What type of issue is this? (place an x in one of the [ ])

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

seratch commented 2 years ago

FYI, we've already implemented this in bolt-python and bolt-java this way:

github-actions[bot] commented 2 years ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

TroutZen commented 2 years ago

Excited for this change for the js sdk!

ElMatella commented 2 years ago

Hey, thank you for this issue. I have a question until this gets implemented, how am I suppose to call deleteInstallation manually?

Currently, I use the app_uninstalled event like this:

app.event('app_uninstalled', async ({ event, logger, context }) => {
  try {
    await database.doc(context.enterpriseId || context.teamId).delete()
  }
  catch (error) {
    logger.error(error);
  }
});

I don't use my installationStore.deleteInstallation at all.. And I'm not sur that the code I made supports enterprise correctly. Could you give me a hand on that one?

Thank you very much

seratch commented 2 years ago

@ElMatella I would suggest implementing the deleteInstallation method for easier migration when the built-in handlers are released. You can check the type definitions related to the method signature below:

ElMatella commented 2 years ago

Hey, thank you for your response.

So, I was just wondering, how can I access the isEnterpriseInstall from the app_uninstalled event?

In bolt, I should be able to access the context.enterpriseId and context.teamId from the app_uninstalled event handler. Does the fact that context.enterpriseId is not null means that isEnterpriseInstall is true?

seratch commented 2 years ago

If your app is removed from the entire enterprise grid organization, the event payload should have only enterprise_id. If the app is removed only from a specific workspace under an enterprise grid org, the payload should have both enterprise_id and team_id.

hiroshinishio commented 1 year ago

Is this still active or will be active in the future?

clementlemon02 commented 1 year ago

Hey, can I check if this is already implemented on bolt-js?

github-actions[bot] commented 4 months ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] commented 4 months ago

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.