public void Handle(EmailStatusUpdate message) { if (message.Status == EmailStatus.Opened || message.Status == EmailStatus.Clicked) { var scheduledEmailSent = new ScheduledEmailSent { CoordinatorId = Data.OriginalMessageData.RequestingCoordinatorId, EmailStatus = message.Status, ScheduledSmsId = Data.ScheduleMessageId, ToAddress = Data.OriginalMessageData.ToAddress, Username = Data.OriginalMessageData.Username }; Bus.Publish(scheduledEmailSent); Bus.SendLocal(new ScheduleStatusChanged { ScheduleId = Data.ScheduleMessageId, Status = MessageStatus.Sent }); MarkAsComplete(); return; } if (message.Status == EmailStatus.Failed || message.Status == EmailStatus.Rejected || message.Status == EmailStatus.Unsubscribed || message.Status == EmailStatus.Complained) { var scheduledEmailFailed = new ScheduledEmailFailed { CoordinatorId = Data.OriginalMessageData.RequestingCoordinatorId, EmailStatus = message.Status, ScheduledSmsId = Data.ScheduleMessageId, ToAddress = Data.OriginalMessageData.ToAddress, Username = Data.OriginalMessageData.Username }; Bus.Publish(scheduledEmailFailed); Bus.SendLocal(new ScheduleStatusChanged { ScheduleId = Data.ScheduleMessageId, Status = MessageStatus.Failed }); MarkAsComplete(); return; } if (message.Status == EmailStatus.Delivered) { Bus.SendLocal(new ScheduleStatusChanged { ScheduleId = Data.ScheduleMessageId, Status = MessageStatus.Delivered }); RequestUtcTimeout <ScheduleEmailDeliveredTimeout>(new TimeSpan(1, 0, 0, 0)); } }
public void Timeout(ScheduleEmailDeliveredTimeout state) { // Haven't heard anything more about the email so we presume that it was successful var scheduledEmailSent = new ScheduledEmailSent { CoordinatorId = Data.OriginalMessageData.RequestingCoordinatorId, EmailStatus = EmailStatus.Delivered, ScheduledSmsId = Data.ScheduleMessageId, ToAddress = Data.OriginalMessageData.ToAddress, Username = Data.OriginalMessageData.Username }; Bus.Publish(scheduledEmailSent); Bus.SendLocal(new ScheduleStatusChanged { ScheduleId = Data.ScheduleMessageId, Status = MessageStatus.Sent }); MarkAsComplete(); }