]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice::saveReplies() uses Profile::fromURI() to handle remote profiles too
authorEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 20:15:51 +0000 (16:15 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 20:15:51 +0000 (16:15 -0400)
classes/Notice.php

index 0eeebfadf374aa7e61c89ca7f56f524f77b15bcb..93456011ad2eda6de4b1c7ad89cc2b6238a84338 100644 (file)
@@ -1014,25 +1014,31 @@ class Notice extends Memcached_DataObject
         if (empty($uris)) {
             return;
         }
+
         $sender = Profile::staticGet($this->profile_id);
 
         foreach (array_unique($uris) as $uri) {
 
-            $user = User::staticGet('uri', $uri);
+            $profile = Profile::fromURI($uri);
 
-            if (!empty($user)) {
-                if ($user->hasBlocked($sender)) {
-                    continue;
-                }
+            if (empty($profile)) {
+                common_log(LOG_WARNING, "Unable to determine profile for URI '$uri'");
+                continue;
+            }
 
-                $reply = new Reply();
+            if ($profile->hasBlocked($sender)) {
+                common_log(LOG_INFO, "Not saving reply to profile {$profile->id} ($uri) from sender {$sender->id} because of a block.");
+                continue;
+            }
 
-                $reply->notice_id  = $this->id;
-                $reply->profile_id = $user->id;
-                common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $user->id");
+            $reply = new Reply();
 
-                $id = $reply->insert();
-            }
+            $reply->notice_id  = $this->id;
+            $reply->profile_id = $profile->id;
+
+            common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $profile->id");
+
+            $id = $reply->insert();
         }
 
         return;