Commit 6afa091d authored by mmn's avatar mmn

Change some Salmon events and similar

Use Profile instead of User and (if we know it) send along the target
profile, so a Diaspora plugin can encrypt to the receiver.
parent f4ed1713
......@@ -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');
......@@ -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;
......@@ -40,8 +40,9 @@ class SalmonQueueHandler extends QueueHandler
$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;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment