OStatus onStartNoticeSourceLink to use exceptions

This commit is contained in:
Mikael Nordfeldth 2014-04-19 22:18:36 +02:00
parent 132be99506
commit 639cf48cc7

View File

@ -523,9 +523,16 @@ class OStatusPlugin extends Plugin
*/
function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
{
if ($notice->source == 'ostatus') {
if ($notice->url) {
$bits = parse_url($notice->url);
// If we don't handle this, keep the event handler going
if ($notice->source != 'ostatus') {
return true;
}
try {
$url = $notice->getUrl();
// If getUrl() throws exception, $url is never set
$bits = parse_url($url);
$domain = $bits['host'];
if (substr($domain, 0, 4) == 'www.') {
$name = substr($domain, 4);
@ -533,14 +540,16 @@ class OStatusPlugin extends Plugin
$name = $domain;
}
$url = $notice->url;
// TRANS: Title. %s is a domain name.
$title = sprintf(_m('Sent from %s via OStatus'), $domain);
// Abort event handler, we have a name and URL!
return false;
}
}
} catch (InvalidUrlException $e) {
// This just means we don't have the notice source data
return true;
}
}
/**
* Send incoming PuSH feeds for OStatus endpoints in for processing.