Skip to content

Commit

Permalink
fixing linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pichsenmeister committed Dec 16, 2019
1 parent c26ff6f commit 3fe57bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
21 changes: 12 additions & 9 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,9 @@ export default class App {
isBlockActionOrInteractiveMessageBody(bodyArg as SlackActionMiddlewareArgs['body'])) ?
(bodyArg as SlackActionMiddlewareArgs<BlockAction | InteractiveMessage>['body']).actions[0] :
(bodyArg as (
Exclude<AnyMiddlewareArgs, SlackEventMiddlewareArgs | SlackActionMiddlewareArgs | SlackViewMiddlewareArgs> |
SlackActionMiddlewareArgs<Exclude<SlackAction, BlockAction | InteractiveMessage>>
Exclude<AnyMiddlewareArgs, SlackEventMiddlewareArgs | SlackActionMiddlewareArgs |
SlackViewMiddlewareArgs> | SlackActionMiddlewareArgs<Exclude<SlackAction, BlockAction |
InteractiveMessage>>
)['body']),
};

Expand Down Expand Up @@ -577,17 +578,19 @@ function singleTeamAuthorization(
const auth: Promise<AuthConstraints> = authorization.botUserId !== undefined && authorization.botId !== undefined ?
Promise.resolve({ botUserId: authorization.botUserId, botId: authorization.botId }) :
client.auth.test({ token: authorization.botToken })
.then(result => {
.then((result) => {
return {
botUserId: (result.user_id as string),
botId: (result.bot_id as string)
}
botId: (result.bot_id as string),
};
});

return async () => ({
botToken: authorization.botToken,
botId: (await auth).botId,
botUserId: (await auth).botUserId,
return () => auth.then((result) => {
return {
botToken: authorization.botToken,
botId: result.botId,
botUserId: result.botUserId,
};
});
}

Expand Down
22 changes: 11 additions & 11 deletions src/ExpressReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,21 @@ function parseRequestBody(
const parsedBody = querystring.parse(stringBody);
if (typeof parsedBody.payload === 'string') {
return JSON.parse(parsedBody.payload);
} else {
return parsedBody;
}
} else if (contentType === 'application/json') {
return parsedBody;

} if (contentType === 'application/json') {
return JSON.parse(stringBody);
} else {
logger.warn(`Unexpected content-type detected: ${contentType}`);
try {
}
logger.warn(`Unexpected content-type detected: ${contentType}`);
try {
// Parse this body anyway
return JSON.parse(stringBody);
} catch (e) {
logger.error(`Failed to parse body as JSON data for content-type: ${contentType}`);
throw e;
}
return JSON.parse(stringBody);
} catch (e) {
logger.error(`Failed to parse body as JSON data for content-type: ${contentType}`);
throw e;
}

}

function receiverAckTimeoutError(message: string): ReceiverAckTimeoutError {
Expand Down

0 comments on commit 3fe57bb

Please sign in to comment.