Skip to content

Commit

Permalink
Fix #57 - Handle case when subscription was deleted and ExpirationDat…
Browse files Browse the repository at this point in the history
…e is unavailable in Entitlement object
  • Loading branch information
charleswhchan committed Nov 19, 2022
1 parent 4b0516e commit 6901b7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/entitlement-sqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ exports.handler = async (event) => {

console.log('entitlementsResponse', entitlementsResponse);

const isExpired = new Date(entitlementsResponse.Entitlements[0].ExpirationDate) < new Date();
const isExpired = entitlementsResponse.hasOwnProperty("Entitlements") === false || entitlementsResponse.Entitlements.length === 0 ||
new Date(entitlementsResponse.Entitlements[0].ExpirationDate) < new Date();

const dynamoDbParams = {
TableName: newSubscribersTableName,
Expand Down

0 comments on commit 6901b7f

Please sign in to comment.