Handle exception from Magic Envelope toXML function

This commit is contained in:
Mikael Nordfeldth 2016-06-23 23:27:18 +02:00
parent 6dcb293ba0
commit a4051945fd
2 changed files with 12 additions and 2 deletions

View File

@ -225,7 +225,12 @@ class DiasporaPlugin extends Plugin
public function onSalmonSlap($endpoint_uri, MagicEnvelope $magic_env, Profile $target=null) public function onSalmonSlap($endpoint_uri, MagicEnvelope $magic_env, Profile $target=null)
{ {
try {
$envxml = $magic_env->toXML($target, 'diaspora'); $envxml = $magic_env->toXML($target, 'diaspora');
} catch (Exception $e) {
common_log(LOG_ERR, sprintf('Could not generate Magic Envelope XML (diaspora flavour) for profile id=='.$target->getID().': '.$e->getMessage()));
return false;
}
// Diaspora wants another POST format (base64url-encoded POST variable 'xml') // Diaspora wants another POST format (base64url-encoded POST variable 'xml')
$headers = array('Content-Type: application/x-www-form-urlencoded'); $headers = array('Content-Type: application/x-www-form-urlencoded');

View File

@ -1407,7 +1407,12 @@ class OStatusPlugin extends Plugin
public function onSalmonSlap($endpoint_uri, MagicEnvelope $magic_env, Profile $target=null) public function onSalmonSlap($endpoint_uri, MagicEnvelope $magic_env, Profile $target=null)
{ {
try {
$envxml = $magic_env->toXML($target); $envxml = $magic_env->toXML($target);
} catch (Exception $e) {
common_log(LOG_ERR, sprintf('Could not generate Magic Envelope XML for profile id=='.$target->getID().': '.$e->getMessage()));
return false;
}
$headers = array('Content-Type: application/magic-envelope+xml'); $headers = array('Content-Type: application/magic-envelope+xml');