Notice->getUrl() for shares would throw exception in some feeds

This commit is contained in:
Mikael Nordfeldth 2014-05-10 13:06:18 +02:00
parent ce23c68d1c
commit 04b7194511
2 changed files with 25 additions and 15 deletions

View File

@ -1493,7 +1493,12 @@ class Notice extends Managed_DataObject
$act->id = $this->uri; $act->id = $this->uri;
$act->time = strtotime($this->created); $act->time = strtotime($this->created);
$act->link = $this->getUrl(); try {
$act->link = $this->getUrl();
} catch (InvalidUrlException $e) {
// The notice is probably a share or similar, which don't
// have a representational URL of their own.
}
$act->content = common_xml_safe_str($this->rendered); $act->content = common_xml_safe_str($this->rendered);
$profile = $this->getProfile(); $profile = $this->getProfile();

View File

@ -38,20 +38,25 @@ class OembedPlugin extends Plugin
'title'=>'oEmbed'),null); 'title'=>'oEmbed'),null);
break; break;
case 'shownotice': case 'shownotice':
$action->element('link',array('rel'=>'alternate', try {
'type'=>'application/json+oembed', $action->element('link',array('rel'=>'alternate',
'href'=>common_local_url( 'type'=>'application/json+oembed',
'oembed', 'href'=>common_local_url(
array(), 'oembed',
array('format'=>'json','url'=>$action->notice->getUrl())), array(),
'title'=>'oEmbed'),null); array('format'=>'json','url'=>$action->notice->getUrl())),
$action->element('link',array('rel'=>'alternate', 'title'=>'oEmbed'),null);
'type'=>'text/xml+oembed', $action->element('link',array('rel'=>'alternate',
'href'=>common_local_url( 'type'=>'text/xml+oembed',
'oembed', 'href'=>common_local_url(
array(), 'oembed',
array('format'=>'xml','url'=>$action->notice->getUrl())), array(),
'title'=>'oEmbed'),null); array('format'=>'xml','url'=>$action->notice->getUrl())),
'title'=>'oEmbed'),null);
} catch (InvalidUrlException $e) {
// The notice is probably a share or similar, which don't
// have a representational URL of their own.
}
break; break;
} }