Skip to content

Commit

Permalink
feat: add isEnterpriseInstall to Context
Browse files Browse the repository at this point in the history
  • Loading branch information
rockingskier committed Jul 2, 2022
1 parent 7eec438 commit 845ff64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,9 @@ export default class App {
error: e,
logger: this.logger,
body: bodyArg,
context: {},
context: {
isEnterpriseInstall,
},
});
}
}
Expand All @@ -854,6 +856,7 @@ export default class App {
const context: Context = {
...authorizeResult,
...event.customProperties,
isEnterpriseInstall,
retryNum: event.retryNum,
retryReason: event.retryReason,
};
Expand Down Expand Up @@ -1329,7 +1332,7 @@ function buildSource<IsEnterpriseInstall extends boolean>(
if (type === IncomingEventType.Event) {
const bodyAsEvent = body as SlackEventMiddlewareArgs['body'];
if (Array.isArray(bodyAsEvent.authorizations) && bodyAsEvent.authorizations[0] !== undefined) {
// The enteprise_id here can be null when the workspace is not in an Enterprise Grid
// The enterprise_id here can be null when the workspace is not in an Enterprise Grid
const theId = bodyAsEvent.authorizations[0].enterprise_id;
return theId !== null ? theId : undefined;
}
Expand Down
4 changes: 4 additions & 0 deletions src/types/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export interface Context extends StringIndexed {
* Enterprise Grid Organization ID.
*/
enterpriseId?: string;
/**
* Is the app installed at an Enterprise level?
*/
isEnterpriseInstall: boolean,

/**
* Retry count of an Events API request (this property does not exist for other requests)
Expand Down

0 comments on commit 845ff64

Please sign in to comment.