diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 8fc9f6c5f6..dbdbe88523 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -345,7 +345,7 @@ class Ostatus_profile extends Managed_DataObject $xml = $entry->getString(); common_log(LOG_INFO, "Posting to Salmon endpoint $this->salmonuri: $xml"); - Salmon::post($this->salmonuri, $xml, $actor->getUser()); + Salmon::post($this->salmonuri, $xml, $actor); } /** @@ -359,7 +359,7 @@ class Ostatus_profile extends Managed_DataObject public function notifyActivity($entry, Profile $actor) { if ($this->salmonuri) { - return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor->getUser()); + return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor, $this->localProfile()); } common_debug(__CLASS__.' error: No salmonuri for Ostatus_profile uri: '.$this->uri); @@ -378,7 +378,8 @@ class Ostatus_profile extends Managed_DataObject if ($this->salmonuri) { $data = array('salmonuri' => $this->salmonuri, 'entry' => $this->notifyPrepXml($entry), - 'actor' => $actor->id); + 'actor' => $actor->getID(), + 'target' => $this->localProfile()->getID()); $qm = QueueManager::get(); return $qm->enqueue($data, 'salmon'); diff --git a/plugins/OStatus/lib/salmon.php b/plugins/OStatus/lib/salmon.php index cdc8e02d77..b964538cbc 100644 --- a/plugins/OStatus/lib/salmon.php +++ b/plugins/OStatus/lib/salmon.php @@ -43,18 +43,18 @@ class Salmon * * @param string $endpoint_uri * @param string $xml string representation of payload - * @param User $user local user profile whose keys we sign with + * @param Profile $user profile whose keys we sign with (must be a local user) * @return boolean success */ - public static function post($endpoint_uri, $xml, User $user, Profile $target=null) + public static function post($endpoint_uri, $xml, Profile $actor, Profile $target=null) { if (empty($endpoint_uri)) { - common_debug('No endpoint URI for Salmon post to '.$user->getUri()); + common_debug('No endpoint URI for Salmon post to '.$actor->getUri()); return false; } try { - $magic_env = MagicEnvelope::signAsUser($xml, $user); + $magic_env = MagicEnvelope::signAsUser($xml, $actor->getUser()); } catch (Exception $e) { common_log(LOG_ERR, "Salmon unable to sign: " . $e->getMessage()); return false; diff --git a/plugins/OStatus/lib/salmonqueuehandler.php b/plugins/OStatus/lib/salmonqueuehandler.php index 334dc14549..fbc03c3954 100644 --- a/plugins/OStatus/lib/salmonqueuehandler.php +++ b/plugins/OStatus/lib/salmonqueuehandler.php @@ -40,8 +40,9 @@ class SalmonQueueHandler extends QueueHandler assert(is_string($data['entry'])); $actor = Profile::getKV($data['actor']); + $target = array_key_exists('target', $data) ? Profile::getKV($data['target']) : null; - Salmon::post($data['salmonuri'], $data['entry'], $actor->getUser()); + Salmon::post($data['salmonuri'], $data['entry'], $actor, $target); // @fixme detect failure and attempt to resend return true;