botkit icon indicating copy to clipboard operation
botkit copied to clipboard

Add Promise to botbuilder-adapter-webex both registerWebhookSubscription functions

Open punithk opened this issue 2 years ago • 12 comments

This is a fix for issue 2217.

The solution wraps the function with promise such that rejects are present and any thrown error can not be easily caught and handled by the user and should not affect existing bots.

Now developers can handle wrong access tokens this way without crashing during webhook subscription:

const adapter = new WebexAdapter({
     access_token: process.env.ACCESS_TOKEN, // access token from https://developer.webex.com
     public_address: process.env.PUBLIC_ADDRESS,  // public url of this app https://myapp.com/
     secret: process.env.SECRET // webhook validation secret - you can define this yourself
});

adapter.registerWebhookSubscription('/api/messages')
     .then()
     .catch(err => {    // <- this would fix the issue
            // Handle the error as per needs
     });

The changes should fix the issue and be backward compatible too.

punithk avatar May 20 '22 08:05 punithk

CLA assistant check
All CLA requirements met.

ghost avatar May 20 '22 08:05 ghost

Promisifying should resolve the issue of application breaking on wrong token case

Dayavats avatar May 23 '22 06:05 Dayavats

Thanks for the suggestion. Looks like it will solve the issue.

Akanksha-270392 avatar May 24 '22 13:05 Akanksha-270392

The above suggestion is appreciated. It look like it will be the solution to the issue.

VaniKaushik-2511 avatar May 25 '22 05:05 VaniKaushik-2511

The solution mentioned above seems to resolve the issue.

Maleeha456 avatar May 26 '22 06:05 Maleeha456

It seems like this solution will solve the issue. Appreciated.

Sayak-Bhattacharjee avatar May 27 '22 05:05 Sayak-Bhattacharjee

The solution mentioned above seems to resolve the issue.Thanks for the suggestion.

Dhananjay220398 avatar May 27 '22 11:05 Dhananjay220398

Thanks for the suggestion. Looks like it will solve the issue.

Adishjain58 avatar May 27 '22 11:05 Adishjain58

Seems like this solution will resolve the issue, Thanks for the suggestion.

Akash2695 avatar May 27 '22 12:05 Akash2695

Thanks for the suggestion. Looks like it will solve the issue.

rashmi0403 avatar May 27 '22 12:05 rashmi0403

I think @punithkrishnamurthy is doing right thing can we get this merged?

Sakshi21197 avatar May 27 '22 12:05 Sakshi21197

facing similar issue while using this package. Please suggest some solution.

Deekshashandilya avatar May 27 '22 15:05 Deekshashandilya