Salmon posts can only be made for local users. More typing!

Since we of course don't have the remote party's private keys anyway.

I made some small fixes in Magicsig class too, removing unnecessary code.
This commit is contained in:
Mikael Nordfeldth
2014-06-02 19:44:57 +02:00
parent 2cd25039af
commit 537dff7987
6 changed files with 22 additions and 57 deletions

View File

@@ -43,18 +43,18 @@ class Salmon
*
* @param string $endpoint_uri
* @param string $xml string representation of payload
* @param Profile $actor local user profile whose keys to sign with
* @param User $user local user profile whose keys we sign with
* @return boolean success
*/
public function post($endpoint_uri, $xml, Profile $actor)
public static function post($endpoint_uri, $xml, User $user)
{
if (empty($endpoint_uri)) {
common_debug('No endpoint URI for Salmon post to '.$actor->getUri());
common_debug('No endpoint URI for Salmon post to '.$user->getUri());
return false;
}
try {
$magic_env = MagicEnvelope::signForProfile($xml, $actor);
$magic_env = MagicEnvelope::signAsUser($xml, $user);
$envxml = $magic_env->toXML();
} catch (Exception $e) {
common_log(LOG_ERR, "Salmon unable to sign: " . $e->getMessage());
@@ -73,7 +73,7 @@ class Salmon
}
if ($response->getStatus() != 200) {
common_log(LOG_ERR, sprintf('Salmon (from profile %d) endpoint %s returned status %s: %s',
$actor->id, $endpoint_uri, $response->getStatus(), $response->getBody()));
$user->id, $endpoint_uri, $response->getStatus(), $response->getBody()));
return false;
}