summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@status.net>2010-08-10 13:36:38 -0700
committerBrion Vibber <brion@status.net>2010-08-10 13:49:11 -0700
commit08fc6053ec55e911b842fd05dafc5e0c99c4e992 (patch)
tree7db0277c84f0f6a7e75b5fb63d8b21dad95c6488
parent4fdfc6b1ce7e5ffa50b24bdddca55cc73d54a09f (diff)
Fix for regression with OStatus mention processing (duplicated new and old style lead to trying to save a reply entry twice).
-rw-r--r--classes/Notice.php7
-rw-r--r--lib/activitycontext.php6
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php2
3 files changed, 9 insertions, 6 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 4646fc6ab..0eeebfadf 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -485,7 +485,7 @@ class Notice extends Memcached_DataObject
function saveKnownUrls($urls)
{
// @fixme validation?
- foreach ($urls as $url) {
+ foreach (array_unique($urls) as $url) {
File::processNew($url, $this->id);
}
}
@@ -893,7 +893,7 @@ class Notice extends Memcached_DataObject
}
$groups = array();
- foreach ($group_ids as $id) {
+ foreach (array_unique($group_ids) as $id) {
$group = User_group::staticGet('id', $id);
if ($group) {
common_log(LOG_ERR, "Local delivery to group id $id, $group->nickname");
@@ -1016,7 +1016,7 @@ class Notice extends Memcached_DataObject
}
$sender = Profile::staticGet($this->profile_id);
- foreach ($uris as $uri) {
+ foreach (array_unique($uris) as $uri) {
$user = User::staticGet('uri', $uri);
@@ -1029,6 +1029,7 @@ class Notice extends Memcached_DataObject
$reply->notice_id = $this->id;
$reply->profile_id = $user->id;
+ common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $user->id");
$id = $reply->insert();
}
diff --git a/lib/activitycontext.php b/lib/activitycontext.php
index 5afbb7fd2..09a457924 100644
--- a/lib/activitycontext.php
+++ b/lib/activitycontext.php
@@ -71,6 +71,7 @@ class ActivityContext
$links = $element->getElementsByTagNameNS(ActivityUtils::ATOM, ActivityUtils::LINK);
+ $attention = array();
for ($i = 0; $i < $links->length; $i++) {
$link = $links->item($i);
@@ -80,11 +81,12 @@ class ActivityContext
// XXX: Deprecate this in favour of "mentioned" from Salmon spec
// http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-salmon-00.html#SALR
if ($linkRel == self::ATTENTION) {
- $this->attention[] = $link->getAttribute(self::HREF);
+ $attention[] = $link->getAttribute(self::HREF);
} elseif ($linkRel == self::MENTIONED) {
- $this->attention[] = $link->getAttribute(self::HREF);
+ $attention[] = $link->getAttribute(self::HREF);
}
}
+ $this->attention = array_unique($attention);
}
/**
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index 77a5e22cc..8f8eb773f 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -681,7 +681,7 @@ class Ostatus_profile extends Memcached_DataObject
common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', $attention_uris));
$groups = array();
$replies = array();
- foreach ($attention_uris as $recipient) {
+ foreach (array_unique($attention_uris) as $recipient) {
// Is the recipient a local user?
$user = User::staticGet('uri', $recipient);
if ($user) {