Beispiel #1
0
        private List <SignalBounce <TKey> > CreateBounceList(AmazonSesNotification sesNotification)
        {
            List <SignalBounce <TKey> > bouncedMessages = new List <SignalBounce <TKey> >();

            if (sesNotification.AmazonSesMessageType == AmazonSesMessageType.Unknown)
            {
                _logger.LogError("Unknown AWS message type received.");
                return(bouncedMessages);
            }
            //parse NDR
            else if (sesNotification.AmazonSesMessageType == AmazonSesMessageType.Bounce)
            {
                foreach (AmazonSesBouncedRecipient recipient in sesNotification.Bounce.BouncedRecipients)
                {
                    BounceType bounceType = sesNotification.Bounce.AmazonBounceType == AmazonBounceType.Permanent
                            ? BounceType.HardBounce
                            : BounceType.SoftBounce;

                    string detailsXml = XmlBounceDetails.DetailsToXml(sesNotification.AmazonSesMessageType
                                                                      , sesNotification.Bounce.AmazonBounceType, sesNotification.Bounce.AmazonBounceSubType);

                    SignalBounce <TKey> bouncedMessage = CreateBouncedMessage(bounceType
                                                                              , sesNotification.Mail, recipient.EmailAddress, detailsXml);

                    bouncedMessages.Add(bouncedMessage);
                }
            }
            //parse complaint
            else if (sesNotification.AmazonSesMessageType == AmazonSesMessageType.Complaint)
            {
                foreach (AmazonSesComplaintRecipient recipient in sesNotification.Complaint.ComplainedRecipients)
                {
                    string detailsXml = XmlBounceDetails.DetailsToXml(sesNotification.AmazonSesMessageType
                                                                      , complaintFeedbackType: sesNotification.Complaint.AmazonComplaintFeedbackType);

                    SignalBounce <TKey> bouncedMessage = CreateBouncedMessage(BounceType.HardBounce
                                                                              , sesNotification.Mail, recipient.EmailAddress, detailsXml);

                    bouncedMessages.Add(bouncedMessage);
                }
            }

            return(bouncedMessages);
        }
Beispiel #2
0
        //methods
        /// <summary>
        /// Handle request from AWS SNS with NDR.
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <returns></returns>
        public List <SignalBounce <TKey> > ParseBounceInfo(string requestMessage)
        {
            //string > sns message
            AmazonSnsMessage message;
            bool             isValid = _amazonSnsManager.ParseRequest(requestMessage, out message);

            if (isValid == false)
            {
                return(new List <SignalBounce <TKey> >());
            }

            //sns message > ses message
            AmazonSesNotification sesNotification = ExtractSesNotification(message);

            if (sesNotification == null)
            {
                return(new List <SignalBounce <TKey> >());
            }

            //ses message > List<SignalBounce<TKey>>
            return(CreateBounceList(sesNotification));
        }