Skip to content
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

Respect custom receivers #271

Merged
merged 3 commits into from
Oct 3, 2019

Conversation

shaydewael
Copy link
Contributor

Summary

Addresses #235

Requirements (place an x in each [ ])

@codecov
Copy link

codecov bot commented Oct 1, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@ff81e06). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #271   +/-   ##
=========================================
  Coverage          ?   59.95%           
=========================================
  Files             ?        7           
  Lines             ?      492           
  Branches          ?      136           
=========================================
  Hits              ?      295           
  Misses            ?      169           
  Partials          ?       28
Impacted Files Coverage Δ
src/App.ts 70.88% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff81e06...d2d584a. Read the comment docs.

src/App.ts Outdated
@@ -160,7 +160,7 @@ export default class App {
this.listeners = [];

// Check for required arguments of ExpressReceiver
if (signingSecret !== undefined) {
if (signingSecret !== undefined && receiver === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change these lines to make it more easy-to-understand:

// Check for required arguments of ExpressReceiver
if (signingSecret !== undefined && receiver === undefined) {
    this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
} else if (receiver === undefined) {
    // Check for custom receiver

How about this?

// Check for required arguments of ExpressReceiver
if (receiver !== undefined) {
    // NOTE: signingSecret would be ignored in this case
    this.receiver = receiver;
} else {
    // no custom receiver given here
    if (signingSecret === undefined) {
        throw errorWithCode(
            'Signing secret not found, so could not initialize the default receiver. ' +
            'Set a signing secret or use a custom receiver.',
            ErrorCode.AppInitializationError,
        );
    } else {
        this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
    }
}

@shaydewael shaydewael merged commit ac9720b into slackapi:master Oct 3, 2019
@shaydewael shaydewael deleted the fix-custom-receiver-ss branch October 3, 2019 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants