Skip to content

Commit

Permalink
Merge pull request #60 from charleswhchan/issue-57
Browse files Browse the repository at this point in the history
Fix #57 - Handle case when subscription was deleted and ExpirationDate is unavailable in Entitlement object
  • Loading branch information
JoseRolles authored Aug 3, 2024
2 parents 19d8bed + 6901b7f commit 48b99bd
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 48b99bd

Please sign in to comment.