untested: improved webhook event handling

This commit is contained in:
Mia Rose Winter 2024-06-03 16:02:36 +02:00
parent 66b14baee8
commit b8bc00b68d
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -44,20 +44,20 @@ public class WebhookController(ILogger<WebhookController> logger, ApplicationDbC
subscriber.UnsubscribeReason = webhookEvent.Response; subscriber.UnsubscribeReason = webhookEvent.Response;
break; break;
case WebhookEventType.Suspension: case WebhookEventType.Suspension:
subscriber.Unsubscribed = true; logger.LogWarning("Received Suspension event, you may have send from an unverifyied domain or exceeded your hourly rate.");
subscriber.UnsubscribeReason ??= "unknown"; return Ok();
break; break;
case WebhookEventType.Unsubscribe: case WebhookEventType.Unsubscribe:
subscriber.Unsubscribed = true; subscriber.Unsubscribed = true;
subscriber.UnsubscribeReason ??= "User Unsubscribed"; subscriber.UnsubscribeReason = "User Unsubscribed";
break; break;
case WebhookEventType.SpamComplaint: case WebhookEventType.SpamComplaint:
subscriber.Unsubscribed = true; subscriber.Unsubscribed = true;
subscriber.UnsubscribeReason ??= "User reported as Spam"; subscriber.UnsubscribeReason = "User reported as Spam";
break; break;
case WebhookEventType.Reject: case WebhookEventType.Reject:
subscriber.Unsubscribed = true; subscriber.Unsubscribed = true;
subscriber.UnsubscribeReason ??= webhookEvent.Reason?.Humanize().Titleize() ?? "Rejected"; subscriber.UnsubscribeReason = webhookEvent.Reason?.Humanize().Titleize() ?? "Rejected";
break; break;
case WebhookEventType.SoftBounce: case WebhookEventType.SoftBounce:
case WebhookEventType.Click: case WebhookEventType.Click: