We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 2d015319 authored by mattl's avatar mattl

Output proper remote info on WebFinger notice resources

parent 7be46410
...@@ -1307,10 +1307,23 @@ class OStatusPlugin extends Plugin ...@@ -1307,10 +1307,23 @@ class OStatusPlugin extends Plugin
function onEndWebFingerNoticeLinks(XML_XRD $xrd, Notice $target) function onEndWebFingerNoticeLinks(XML_XRD $xrd, Notice $target)
{ {
$author = $target->getProfile(); $salmon_url = null;
$profiletype = $this->profileTypeString($author); $actor = $target->getProfile();
$salmon_url = common_local_url("{$profiletype}salmon", array('id' => $author->id)); if ($actor->isLocal()) {
$xrd->links[] = new XML_XRD_Element_Link(Salmon::REL_SALMON, $salmon_url); $profiletype = $this->profileTypeString($actor);
$salmon_url = common_local_url("{$profiletype}salmon", array('id' => $actor->getID()));
} else {
try {
$oprofile = Ostatus_profile::fromProfile($actor);
$salmon_url = $oprofile->salmonuri;
} catch (Exception $e) {
// Even though it's not a local user, we couldn't get an Ostatus_profile?!
}
}
// Ostatus_profile salmon URL may be empty
if (!empty($salmon_url)) {
$xrd->links[] = new XML_XRD_Element_Link(Salmon::REL_SALMON, $salmon_url);
}
return true; return true;
} }
......
...@@ -20,17 +20,27 @@ class WebFingerResource_Notice extends WebFingerResource ...@@ -20,17 +20,27 @@ class WebFingerResource_Notice extends WebFingerResource
public function updateXRD(XML_XRD $xrd) public function updateXRD(XML_XRD $xrd)
{ {
if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) { if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) {
$xrd->links[] = new XML_XRD_Element_Link('alternate', if ($this->object->isLocal()) {
$xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow', common_local_url('ApiStatusesShow',
array('id'=>$this->object->id, array('id'=>$this->object->id,
'format'=>'atom')), 'format'=>'atom')),
'application/atom+xml'); 'application/atom+xml');
$xrd->links[] = new XML_XRD_Element_Link('alternate', $xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow', common_local_url('ApiStatusesShow',
array('id'=>$this->object->id, array('id'=>$this->object->id,
'format'=>'json')), 'format'=>'json')),
'application/json'); 'application/json');
} else {
try {
$xrd->links[] = new XML_XRD_Element_Link('alternate',
$this->object->getUrl(),
'text/html');
} catch (InvalidUrlException $e) {
// don't do a fallback in webfinger
}
}
Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object)); Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment