Fixed: Activity link when no wall entry is available

This commit is contained in:
Lucas Bartholemy 2015-09-05 19:04:35 +02:00
parent 056ae54a15
commit 43d1360d07
2 changed files with 7 additions and 4 deletions

View File

@ -52,14 +52,16 @@ class LinkController extends Controller
if ($activity !== null && $activity->content->canRead()) {
$json['success'] = 'true';
$json['wallEntryId'] = '';
$json['wallEntryId'] = '0';
$source = $activity->getSource();
if ($source instanceof ContentActiveRecord || $source instanceof ContentAddonActiveRecord) {
$json['wallEntryId'] = $source->content->getFirstWallEntryId();
$json['permaLink'] = $source->content->getUrl();
} else {
$json['permaLink'] = $activity->content->getUrl();
}
$json['permaLink'] = $activity->content->getUrl();
}
return $json;

View File

@ -5,10 +5,11 @@ function activityShowItem(activityId) {
$.getJSON(activityInfoUrl.replace('-id-', activityId), function (data) {
if (data.success) {
if (mainStream) {
console.log(data);
if (typeof mainStream !== "undefined" && data['wallEntryId'] != 0) {
mainStream.showItem(data['wallEntryId']);
} else {
window.location.replace(data['url']);
window.location.replace(data['permaLink']);
}
} else {
alert("Error: Could not find activity location!");