summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-02 16:58:55 -0400
committerEvan Prodromou <evan@status.net>2010-09-02 16:58:55 -0400
commit82b1d6daefc29c870ea71b29ab851153642f270b (patch)
tree61db5e4fcee85ae0b2e94563e50c78ca794bcf4f /classes
parent7517409bf16137a9d8a420b7358f30fa55945ba0 (diff)
parentebcd8644a51b66d73971d581789e7c70b82007b2 (diff)
Merge branch 'swat0' into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php28
-rw-r--r--classes/Profile.php21
2 files changed, 38 insertions, 11 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 5a70f70b6..14477b1b5 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1019,25 +1019,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;
diff --git a/classes/Profile.php b/classes/Profile.php
index d7617f0b7..8f8679550 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -960,4 +960,25 @@ class Profile extends Memcached_DataObject
return $feed;
}
+
+ static function fromURI($uri)
+ {
+ $profile = null;
+
+ if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
+ // Get a local user or remote (OMB 0.1) profile
+ $user = User::staticGet('uri', $uri);
+ if (!empty($user)) {
+ $profile = $user->getProfile();
+ } else {
+ $remote_profile = Remote_profile::staticGet('uri', $uri);
+ if (!empty($remote_profile)) {
+ $profile = Profile::staticGet('id', $remote_profile->profile_id);
+ }
+ }
+ Event::handle('EndGetProfileFromURI', array($uri, $profile));
+ }
+
+ return $profile;
+ }
}