-
Notifications
You must be signed in to change notification settings - Fork 662
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
Add support for deletion of an installation (InstallationStore / MemoryInstallationStore) #1272
Add support for deletion of an installation (InstallationStore / MemoryInstallationStore) #1272
Conversation
// returns nothing | ||
deleteInstallation: async (installQuery) => { | ||
// replace myDB.get with your own database or OEM getter | ||
if (query.isEnterpriseInstall && query.enterpriseId !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the same error for fetchInstallation
method?
if (query.isEnterpriseInstall && query.enterpriseId !== undefined) { | |
if (installQuery.isEnterpriseInstall && installQuery.enterpriseId !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on both of these. Will update!
// org wide app installation deletion | ||
return await myDB.delete(installQuery.enterpriseId); | ||
} | ||
if (query.teamId !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (query.teamId !== undefined) { | |
if (installQuery.teamId !== undefined) { |
The changes are fine. While reviewing this, I noticed that memory store does not support user tokens. We may want to add some comments to // using a javascript object as a makeshift database for development
// storing user tokens is not supported
interface DevDatabase {
[teamIdOrEnterpriseId: string]: Installation;
} |
@@ -456,6 +456,8 @@ export interface InstallationStore { | |||
logger?: Logger): Promise<void>; | |||
fetchInstallation: | |||
(query: InstallationQuery<boolean>, logger?: Logger) => Promise<Installation<'v1' | 'v2', boolean>>; | |||
deleteInstallation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making this optional incase folks have created their own installationStores. By making it required, it would mean their installationStores are invalid when they upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, great point. Thanks.
@seratch how does memoryStore not support userTokens? It stores the entire installation object which should contain the userToken. That would then get attached to context in bolt |
@stevengill If the internal datastore supports user tokens too, the key should not be interface DevDatabase {
[teamIdOrEnterpriseId: string]: Installation;
} Your app may ask an admin to install the bot and ask other end users to install the app with a set of user token scopes (this is a common scenario). Your app may want to look up user tokens by a user ID as necessary. The simplest interface (which does not support historical data) would be like this: interface DevDatabase {
[teamIdOrEnterpriseId: string]: {
bot?: Installation,
[userId: string]: Installation
}
} |
Ooo good point! We should update our memory install store and examples to this! |
@stevengill Also, as the Python/Java's built-in installation stores support historical data as the default way to cover any use cases including webhooks (custom implementations do not need to have historical data). Here are examples: Python SQLAlchemy, Java S3 The |
Summary
Fixes #1271
Adds
deleteInstallation
to theMemoryInstallationStore
class, as well as to theInstallationStore
interface.Requirements (place an
x
in each[ ]
)