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 1, 2022
1 parent 7eec438 commit b81d900
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ export default class App {
const context: Context = {
...authorizeResult,
...event.customProperties,
isEnterpriseInstall,
retryNum: event.retryNum,
retryReason: event.retryReason,
};
Expand Down Expand Up @@ -1329,7 +1330,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 b81d900

Please sign in to comment.