/// <summary> /// /// </summary> /// <param name="email"></param> /// <exception cref="ArgumentException">On failure to parse some aspect of the email</exception> public void HandleEmail(IEmail email) { if (IsGoogleVoiceEmail(email.Header.From)) { ServiceLocator.Current.Log.Information("IsGoogleVoiceEmail == true"); // Extract the message Message message = GvEmailParser.ParseMessage(email); // Send it to all of the recipient's push endpoints SendMessage(message); } else if (IsEmailForwardPermissionMail(email.Header.From, email.Header.Subject)) { ServiceLocator.Current.Log.Information("IsEmailForwardPermissionMail == true"); string link = GvEmailParser.ParsePermission(email); string userEmail = GvEmailParser.ParsePermissionForUserEmail(email); bool clicked = ServiceLocator.Current.LinkClicker.Click(link); if (clicked && userEmail != null) { ServiceLocator.Current.Log.Information("Email forward request successful."); // Notify the user of success Message message = new Message() { Body = "Forwarding setup successfully!", Number = "avoice", Sender = "aVoice Push", ThreadId = null, Type = null, UserEmail = userEmail }; SendMessage(message); } else if (userEmail != null) { ServiceLocator.Current.Log.Error("Failed to accept forward request. link: {0}. userEmail: {1}. clicked: {2}", link, userEmail, clicked ? "true" : "false"); // Ugh, we failed Message message = new Message() { Body = "Confirmation code: " + GvEmailParser.ParsePermissionForCode(email), Number = "avoice", Sender = "aVoice Push", ThreadId = null, Type = null, UserEmail = userEmail }; SendMessage(message); } } else { ServiceLocator.Current.Log.Warning("We've received an email that we don't have logic to handle. From: " + email.Header.From); } }
public void SendMessage(Message message, List<MessageRecipient> recipients, string senderDisplayName = null) { foreach (var messageSender in _messageSenders) { messageSender.SendMessage(message, recipients, senderDisplayName); } }
public void SendMessage(Message message, IReadOnlyCollection<MessageRecipient> recipients) { foreach (var messageRecipient in recipients) { Debug.WriteLine("To: {0} <{1}>\r\nSubject: {2}\r\nMessage: {3}", messageRecipient.Name, messageRecipient.EmailAddress, message.Subject, message.Body); } }
public void SendMessage(Message message, IReadOnlyCollection<MessageRecipient> recipients, string senderDisplayName = null) { foreach (var messageRecipient in recipients) { Debug.WriteLine("From:{0} To: {1} <{2}>\r\nSubject: {3}\r\nMessage: {4}", senderDisplayName, messageRecipient.Name, messageRecipient.EmailAddress, message.Subject, message.Body); } }
public ActionResult SendMessageToVolunteersByDisaster(SendMessageToAllVolunteersByDisasterViewModel model) { if (!ModelState.IsValid) { PopulateSendMessageViewModel(model); return View("CreateMessage", model); } var recipientCriterion = new RecipientCriterion(model.DisasterId, model.ClusterId); var message = new Message(model.Subject, model.Message); _messageSvc.SendMessageToDisasterVolunteers(recipientCriterion, message); return View(model); }
public void SendMessage(Message message, List<MessageRecipient> recipients, string senderDisplayName = null) { foreach (var messageSender in _messageSenders) { if (message.IsSMSMessage) { if (messageSender is SMSMessageSender) messageSender.SendMessage(message, recipients, senderDisplayName); } else if (!(messageSender is SMSMessageSender)) messageSender.SendMessage(message, recipients, senderDisplayName); } }
public void SendMessage(Message message, List<MessageRecipient> recipients) { foreach (var messageSender in _messageSenders) { try { messageSender.SendMessage(message, recipients); } catch (Exception) { //TODO: Add logging implementation--awaiting decision from Bill } } }
public ActionResult SendMessageToVolunteersByDisaster(SendMessageToAllVolunteersByDisasterViewModel model) { if (!ModelState.IsValid) { PopulateSendMessageViewModel(model); return View("CreateMessage", model); } var sender = model.DisasterName + " - Coordinator"; var recipientCriterion = new RecipientCriterion(model.DisasterId, model.ClusterId, model.ClusterCoordinatorsOnly, model.CheckedInOnly); var message = new Message(model.Subject, model.Message); _messageSvc.SendMessageToDisasterVolunteers(message, recipientCriterion, sender); return View(model); }
public void SendMessageToDisasterVolunteers(RecipientCriterion recipientCriterion, Message message) { var volunteers = _adminSvc.GetVolunteersForDate(recipientCriterion.DisasterId, DateTime.Today); var messageRecipients = new List<MessageRecipient>(); foreach (var volunteer in volunteers) { messageRecipients.Add(new MessageRecipient { EmailAddress = volunteer.Email, Name = string.Format("{0} {1}", volunteer.FirstName, volunteer.LastName) }); } _msgCoordinatorSvc.SendMessage(message, messageRecipients); }
public void SendMessageToDisasterVolunteers(RecipientCriterion recipientCriterion, Message message) { // Get volunteers for disaster where DateTime.Today between person.StartDate and person.EndDate // var volunteers = _adminSvc.GetVolunteersForDate(recipientCriterion.DisasterId, DateTime.Today); }
/// <summary> /// Distribute the given message to all of the recipient's push endpoints. /// </summary> /// <param name="message"></param> private void SendMessage(Message message) { ServiceLocator.Current.PushSender.Send(message.UserEmail, message.Sender, message.Body); }
public void RequeueMessage(Message message) { messageQueue.Add(message); }