From f7479e3f57f19715098e961403a941a3b4418216 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 2 Jun 2014 19:33:09 +0200 Subject: [PATCH] Prepare for WebFinger magicsig data for remote profiles --- plugins/OStatus/OStatusPlugin.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 37099c2452..b80f965d81 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -1341,16 +1341,18 @@ class OStatusPlugin extends Plugin $xrd->links[] = new XML_XRD_Element_Link(Salmon::NS_REPLIES, $salmon_url); $xrd->links[] = new XML_XRD_Element_Link(Salmon::NS_MENTIONS, $salmon_url); - // Get this user's keypair - $magickey = Magicsig::getKV('user_id', $target->id); - if (!($magickey instanceof Magicsig)) { - // No keypair yet, let's generate one. - $magickey = new Magicsig(); - $magickey->generate($target->id); + // Get this profile's keypair + $magicsig = Magicsig::getKV('user_id', $target->id); + if (!$magicsig instanceof Magicsig && $target->isLocal()) { + // No keypair yet, let's generate one. Only for local users. + $magicsig = new Magicsig(); + $magicsig->generate($target->getUser()); } - $xrd->links[] = new XML_XRD_Element_Link(Magicsig::PUBLICKEYREL, - 'data:application/magic-public-key,'. $magickey->toString(false)); + if ($magicsig instanceof Magicsig) { + $xrd->links[] = new XML_XRD_Element_Link(Magicsig::PUBLICKEYREL, + 'data:application/magic-public-key,'. $magicsig->toString(false)); + } // TODO - finalize where the redirect should go on the publisher $xrd->links[] = new XML_XRD_Element_Link('http://ostatus.org/schema/1.0/subscribe',