OStatus onStartNoticeSourceLink to use exceptions
This commit is contained in:
parent
132be99506
commit
639cf48cc7
|
@ -523,23 +523,32 @@ class OStatusPlugin extends Plugin
|
||||||
*/
|
*/
|
||||||
function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
|
function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
|
||||||
{
|
{
|
||||||
if ($notice->source == 'ostatus') {
|
// If we don't handle this, keep the event handler going
|
||||||
if ($notice->url) {
|
if ($notice->source != 'ostatus') {
|
||||||
$bits = parse_url($notice->url);
|
return true;
|
||||||
$domain = $bits['host'];
|
}
|
||||||
if (substr($domain, 0, 4) == 'www.') {
|
|
||||||
$name = substr($domain, 4);
|
try {
|
||||||
} else {
|
$url = $notice->getUrl();
|
||||||
$name = $domain;
|
// If getUrl() throws exception, $url is never set
|
||||||
}
|
|
||||||
|
$bits = parse_url($url);
|
||||||
$url = $notice->url;
|
$domain = $bits['host'];
|
||||||
// TRANS: Title. %s is a domain name.
|
if (substr($domain, 0, 4) == 'www.') {
|
||||||
$title = sprintf(_m('Sent from %s via OStatus'), $domain);
|
$name = substr($domain, 4);
|
||||||
return false;
|
} else {
|
||||||
}
|
$name = $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user