/** * Process a incoming email POST request. * @param object $update The email data * @return array Representation of processing results. */ public function process_inbound_email($update) { $command = Prompt_Command_Handling::make_command($update->data); if (!$command) { return null; } $command->execute(); return 'delivered'; }
/** * Add individual message values based on user data and an optional resend command. * * Sets to_name, to_address, from_name, and recipient_values. * * @since 2.0.0 * * @param array $user_data * @param Prompt_Interface_Command $resend_command * @return $this */ public function add_agreement_recipient(array $user_data, Prompt_Interface_Command $resend_command = null) { $this->users_data[] = $user_data; $command = $resend_command; $notice_html = $this->resend_notice_html(); $notice_text = $this->resend_notice_text(); $email_address = $user_data['user_email']; if (!$resend_command) { $command = new Prompt_Register_Subscribe_Command(); $notice_html = ''; $notice_text = ''; $command->save_subscription_data($this->lists, $email_address, $user_data); } $values = array('to_address' => $email_address, 'reply_to' => array('trackable-address' => Prompt_Command_Handling::get_command_metadata($command)), 'notice_html' => $notice_html, 'notice_text' => $notice_text); if (isset($user_data['display_name'])) { $values['to_name'] = $user_data['display_name']; } $this->add_individual_message_values($values); return $this; }
/** * Add recipient-specific values for an email. * * @since 2.0.0 * * @param WP_User $recipient * @return $this */ protected function add_recipient(WP_User $recipient) { $unsubscribe_link = new Prompt_Unsubscribe_Link($recipient); $command = new Prompt_Comment_Command(); $command->set_post_id($this->prompt_post->id()); $command->set_user_id($recipient->ID); $command->set_parent_comment_id($this->comment->comment_ID); $values = array('id' => $recipient->ID, 'to_name' => $recipient->display_name, 'to_address' => $recipient->user_email, 'subject' => $this->subscriber_subject($recipient), 'unsubscribe_url' => $unsubscribe_link->url(), 'subscriber_comment_intro_html' => $this->subscriber_comment_intro_html($recipient), 'subscriber_comment_intro_text' => $this->subscriber_comment_intro_text($recipient), 'reply_to' => $this->trackable_address(Prompt_Command_Handling::get_command_metadata($command))); $values = array_merge($values, Prompt_Command_Handling::get_comment_reply_macros($this->previous_comments, $recipient->ID)); return $this->add_individual_message_values($values); }
/** * @since 2.0.0 */ protected function forward() { $text = $this->get_message_text(); $from_user = get_user_by('id', $this->from_user_id); $to_user = get_user_by('id', $this->to_user_id); $command = new Prompt_Forward_Command(); $command->set_keys(array('', '', $this->to_user_id, $this->from_user_id)); $template_data = array('sender' => $from_user, 'message' => $text); $html_template = new Prompt_Template('forward-email.php'); $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $to_user->user_email, 'from_name' => $from_user->display_name, 'subject' => $this->message->subject, 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN, 'reply_to' => array('trackable-address' => Prompt_Command_Handling::get_command_metadata($command)))); Prompt_Factory::make_mailer($batch)->send(); }
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(); }
/** * If replyable returns all comment reply command macros, otherwise a command macro to forward replies to * the post author. * * @since 2.0.0 * * @param int $recipient_id * @param Prompt_Interface_Subscribable $subscribed_list * @return array */ protected function mail_command_values($recipient_id, Prompt_Interface_Subscribable $subscribed_list) { $values = array(); if ($this->replyable) { $command = new Prompt_New_Post_Comment_Command(); $command->set_post_id($this->context->get_post()->id()); $command->set_user_id($recipient_id); $values = Prompt_Command_Handling::get_comment_reply_macros($this->comments, $recipient_id); } else { $command = new Prompt_Forward_Command(); $command->set_from_user_id($recipient_id); $command->set_to_user_id($this->context->get_post()->get_wp_post()->post_author); $command->set_subscription_object($subscribed_list); } $values['reply_to'] = $this->trackable_address(Prompt_Command_Handling::get_command_metadata($command)); return $values; }