protected function send_notifications($recipient_ids)
 {
     $template_data = array('post' => $this->prompt_post, 'comment_header' => true);
     /**
      * Filter comment email template data.
      *
      * @param array $template_data {
      * @type Prompt_post $post
      * @type bool $comment_header
      * }
      */
     $template_data = apply_filters('prompt/comment_flood_email/template_data', $template_data);
     $html_template = new Prompt_Template('comment-flood-email.php');
     $text_template = new Prompt_Text_Template('comment-flood-email-text.php');
     $footnote_html = sprintf(__('You received this email because you\'re subscribed to %s.', 'Postmatic'), $this->prompt_post->subscription_object_label());
     $batch = new Prompt_Email_Batch(array('subject' => __('We\'re pausing comment notices for you.', 'Postmatic'), 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::SUBSCRIPTION, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => Prompt_Content_Handling::reduce_html_to_utf8($footnote_html)));
     foreach ($recipient_ids as $recipient_id) {
         $subscriber = get_userdata($recipient_id);
         if (!$subscriber or !$subscriber->user_email) {
             continue;
         }
         $command = new Prompt_Comment_Flood_Command();
         $command->set_post_id($this->prompt_post->id());
         $command->set_user_id($recipient_id);
         $batch->add_individual_message_values(array('to_address' => $subscriber->user_email, 'reply_to' => Prompt_Email_Batch::trackable_address(Prompt_Command_Handling::get_command_metadata($command))));
     }
     /**
      * Filter comment notification email batch.
      *
      * @param Prompt_Email_Batch $batch
      * @param array $template_data see prompt/comment_email/template_data
      */
     $batch = apply_filters('prompt/comment_flood_email_batch', $batch, $template_data);
     Prompt_Factory::make_mailer($batch)->send();
 }
 /**
  * Builds an email batch with content and recipients based on a comment.
  *
  * @since 2.0.0
  *
  * @param object $comment Target comment
  * @param Prompt_Comment_Flood_Controller
  */
 public function __construct($comment, Prompt_Comment_Flood_Controller $flood_controller = null)
 {
     $this->comment = $comment;
     $this->prompt_post = $prompt_post = new Prompt_Post($this->comment->comment_post_ID);
     $this->flood_controller = $flood_controller ? $flood_controller : new Prompt_Comment_Flood_Controller($comment);
     $this->subscribed_post_title_link = html('a', array('href' => get_permalink($this->prompt_post->id())), get_the_title($this->prompt_post->id()));
     $comment_author = $this->comment_author_user();
     $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport');
     $parent_comment = $parent_author = null;
     $parent_author_name = '';
     $template_file = 'new-comment-email.php';
     if ($this->comment->comment_parent) {
         $parent_comment = get_comment($this->comment->comment_parent);
         $parent_author = get_userdata($parent_comment->user_id);
         $parent_author_name = $parent_author ? $parent_author->display_name : $parent_comment->comment_author;
         $parent_author_name = $parent_author_name ? $parent_author_name : __('Anonymous', 'Postmatic');
         $template_file = $is_api_delivery ? 'comment-reply-email.php' : $template_file;
     }
     $this->parent_comment = $parent_comment;
     $this->parent_author = $parent_author;
     $this->parent_author_name = $parent_author_name;
     $commenter_name = $comment_author ? $comment_author->display_name : $this->comment->comment_author;
     $commenter_name = $commenter_name ? $commenter_name : __('Anonymous', 'Postmatic');
     $this->commenter_name = $commenter_name;
     $post_author = get_userdata($prompt_post->get_wp_post()->post_author);
     $post_author_name = $post_author ? $post_author->display_name : __('Anonymous', 'Postmatic');
     $this->set_previous_comments();
     $template_data = array('comment_author' => $comment_author, 'comment' => $this->comment, 'commenter_name' => $commenter_name, 'subscribed_post' => $prompt_post, 'subscribed_post_author_name' => $post_author_name, 'subscribed_post_title_link' => $this->subscribed_post_title_link, 'previous_comments' => $this->previous_comments, 'parent_author' => $parent_author, 'parent_author_name' => $parent_author_name, 'parent_comment' => $parent_comment, 'comment_header' => true, 'is_api_delivery' => $is_api_delivery);
     /**
      * Filter comment email template data.
      *
      * @param array $template_data {
      * @type WP_User $comment_author
      * @type WP_User $subscriber
      * @type object $comment
      * @type Prompt_post $subscribed_post
      * @type string $subscribed_post_author_name
      * @type array $previous_comments
      * @type WP_User $parent_author
      * @type string $parent_author_name
      * @type object $parent_comment
      * @type bool $comment_header
      * @type bool $is_api_delivery
      * }
      */
     $template_data = apply_filters('prompt/comment_email/template_data', $template_data);
     $html_template = new Prompt_Template($template_file);
     $text_template = new Prompt_Text_Template(str_replace('.php', '-text.php', $template_file));
     /* translators: %1$s is a subscription list title, %2$s the unsubscribe command */
     $footnote_format = __('You received this email because you\'re subscribed to %1$s. To no longer receive other comments or replies in this discussion reply with the word \'%2$s\'.', 'Postmatic');
     $message_template = array('from_name' => $commenter_name, 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::COMMENT, 'subject' => '{{{subject}}}', 'reply_to' => '{{{reply_to}}}', 'footnote_html' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(), "<a href=\"{$this->unsubscribe_mailto()}\">" . Prompt_Unsubscribe_Matcher::target() . "</a>"), 'footnote_text' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(Prompt_Enum_Content_Types::TEXT), Prompt_Unsubscribe_Matcher::target()));
     parent::__construct($message_template);
     $recipient_ids = array_diff($this->flood_controlled_recipient_ids(), $this->sent_recipient_ids());
     /**
      * Filter whether to send new comment notifications.
      *
      * @param boolean $send Default true.
      * @param object $comment
      * @param array $recipient_ids
      */
     if (!apply_filters('prompt/send_comment_notifications', true, $this->comment, $recipient_ids)) {
         return null;
     }
     $this->add_recipients($recipient_ids);
 }