Skip to content

Commit

Permalink
chore: added backup message for cancelled subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoreMihai committed Jun 20, 2022
1 parent c2cfffb commit 5476206
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CompressImagesFunction/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
},
"extensions": {
"queues": {
"batchSize": 2
"batchSize": 2,
"maxDequeueCount" : 2,
"newBatchThreshold" : 1
}
}
}
12 changes: 12 additions & 0 deletions WebHook/WebHookFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,18 @@ await marketplaceTable.ExecuteAsync(TableOperation.InsertOrMerge(new Marketplace
return hook.action;
case "cancelled":
await marketplaceTable.DropRow(hook.marketplace_purchase.account.id, hook.marketplace_purchase.account.login);
if (KnownGitHubs.Plans.ContainsKey(hook.marketplace_purchase.plan.id) &&
KnownGitHubs.Plans[hook.marketplace_purchase.plan.id] != 0)
{
await backupMessages.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(
new BackupMessage
{
PlanId = hook.marketplace_purchase.plan.id,
Price = hook.marketplace_purchase.plan.monthly_price_in_cents / 100,
SaleType = "cancelled"
})));
}

logger.LogInformation("ProcessMarketplacePurchaseAsync/cancelled {PlanId} for {Owner}", hook.marketplace_purchase.plan.id, hook.marketplace_purchase.account.login);
return "cancelled";
default:
Expand Down

0 comments on commit 5476206

Please sign in to comment.