From 3360212e81ba0ab4d2204b3c81c4616641608747 Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher <saschagros+test@gmail.com>
Date: Thu, 3 Mar 2011 14:15:05 +0100
Subject: [PATCH] by Berdir: Enforce type user in role.

---
 privatemsg_rules/privatemsg_rules.rules.inc |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/privatemsg_rules/privatemsg_rules.rules.inc b/privatemsg_rules/privatemsg_rules.rules.inc
index 21a40e7..8398d49 100644
--- a/privatemsg_rules/privatemsg_rules.rules.inc
+++ b/privatemsg_rules/privatemsg_rules.rules.inc
@@ -382,6 +382,9 @@ function privatemsg_rules_rules_defaults() {
  */
 function privatemsg_rules_new($subject, $body, $recipient, $author) {
   rules_log(t('Writing new message with subject %subject to %user from %author', array('%subject' => $subject, '%user' => $recipient->name, '%author' => $author->name)));
+  // Enforce type user on recipient, see http://drupal.org/node/1079644.
+  $recipient->type = 'user';
+  $recipient->recipient = $recipient->uid;
   $result = privatemsg_new_thread(array($recipient), $subject, $body, array('author' => $author));
   if ($result['success']) {
     rules_log(t('New message sucessfully sent, !link', array('!link' => l($subject, 'messages/view/' . $result['message']['thread_id']))));
-- 
1.7.4.1

