Notice::saveReplies() uses Profile::fromURI() to handle remote profiles too

This commit is contained in:
Evan Prodromou 2010-09-01 16:15:51 -04:00
parent 7bec455a21
commit a2de30b767

View File

@ -1014,26 +1014,32 @@ class Notice extends Memcached_DataObject
if (empty($uris)) { if (empty($uris)) {
return; return;
} }
$sender = Profile::staticGet($this->profile_id); $sender = Profile::staticGet($this->profile_id);
foreach (array_unique($uris) as $uri) { foreach (array_unique($uris) as $uri) {
$user = User::staticGet('uri', $uri); $profile = Profile::fromURI($uri);
if (!empty($user)) { if (empty($profile)) {
if ($user->hasBlocked($sender)) { common_log(LOG_WARNING, "Unable to determine profile for URI '$uri'");
continue;
}
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; continue;
} }
$reply = new Reply(); $reply = new Reply();
$reply->notice_id = $this->id; $reply->notice_id = $this->id;
$reply->profile_id = $user->id; $reply->profile_id = $profile->id;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $user->id");
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $profile->id");
$id = $reply->insert(); $id = $reply->insert();
} }
}
return; return;
} }