generate the correct service permalink

This commit is contained in:
friendica 2015-02-08 18:31:51 -08:00
parent 7893b64955
commit 64191de5e7
3 changed files with 30 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<style>
section { position: relative; margin-left: 15px;}
nav { z-index: 9999; position: fixed; width: 100%; top: 0; left: 0; }
header { z-index: 10000; }
header { z-index: 10000; }
.tr {
clear: both;
@ -30,7 +30,7 @@ body::after {
right: 0;
position: absolute;
opacity: 0.5;
z-index: -1;
z-index: -1;
}
</style>

View File

@ -772,7 +772,6 @@ function diaspora_request($importer,$xml) {
function diaspora_post($importer,$xml,$msg) {
$a = get_app();
@ -898,8 +897,8 @@ function diaspora_post($importer,$xml,$msg) {
}
// this won't work for Friendica or Redmatrix but it's probably the best we can do.
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = service_plink($contact,$guid);
$datarray['uid'] = $importer['channel_id'];
@ -1116,8 +1115,7 @@ function diaspora_reshare($importer,$xml,$msg) {
}
}
// This won't work on redmatrix
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = service_plink($contact,$guid);
$datarray['uid'] = $importer['channel_id'];
$datarray['mid'] = $datarray['parent_mid'] = $guid;
@ -1198,7 +1196,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
return;
}
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = service_plink($contact,$guid);
$datarray = array();

View File

@ -1523,3 +1523,27 @@ function scrape_feed($url) {
return $ret;
}
function service_plink($contact, $guid) {
$plink = '';
$m = parse_url($contact['xchan_url']);
if($m) {
$url = $scheme . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
}
else
$url = 'https://' . substr($contact['xchan_addr'],strpos($contact['xchan_addr'],'@')+1);
$handle = substr($contact['xchan_addr'], 0, strpos($contact['xchan_addr'],'@'));
if($contact['xchan_network'] === 'diaspora')
$plink = $url . '/posts/' . $guid;
if($contact['xchan_network'] === 'friendica-over-diaspora')
$plink = $url . '/display/' . $handle . '/' . $guid;
if($contact['xchan_network'] === 'zot')
$plink = $url . '/channel/' . $handle . '?f=&mid=' . $guid;
return $plink;
}