Skip to content

Commit

Permalink
Log additional webhook registration details
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver committed Sep 16, 2024
1 parent 8d9e943 commit 19728b1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/TuyaOAuth2Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,11 @@ export default class TuyaOAuth2Client extends OAuth2Client<TuyaOAuth2Token> {
// Remove duplicate registrations
const combinedKeys = Array.from(new Set([...keys, ...otherKeys]));

if (combinedKeys.length === 0 && this.webhook) {
await this.webhook.unregister();
this.log('Unregistered Webhook');
if (this.webhook) {
await this.webhook
.unregister()
.then(() => this.log('Unregistered existing webhook'))
.catch(this.error);
}

if (combinedKeys.length > 0) {
Expand All @@ -367,10 +369,10 @@ export default class TuyaOAuth2Client extends OAuth2Client<TuyaOAuth2Token> {
.catch(err => this.error(`Error Handling Webhook Message: ${err.message}`));
});

this.log('Registered Webhook');
this.log('Registered webhook', JSON.stringify(combinedKeys));
}
})
.catch(err => this.error(`Error Updating Webhook: ${err.message}`));
.catch(err => this.error(`Error updating webhook: ${err.message}`));
}, 1000);
}
}
Expand Down

0 comments on commit 19728b1

Please sign in to comment.