diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 7 | ||||
-rwxr-xr-x | include/diaspora.php | 10 | ||||
-rw-r--r-- | include/network.php | 24 |
3 files changed, 29 insertions, 12 deletions
diff --git a/include/attach.php b/include/attach.php index f61fea9a5..f878a886f 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1258,15 +1258,10 @@ function recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_ } function in_group($group_id) { - //TODO: make these two queries one with a join. - $x = q("SELECT id FROM groups WHERE hash = '%s'", + $r = q("SELECT xchan FROM group_member left join groups on group_member.gid = group.id WHERE hash = '%s' ", dbesc($group_id) ); - $r = q("SELECT xchan FROM group_member WHERE gid = %d", - intval($x[0]['id']) - ); - foreach($r as $ig) { $group_members[] = $ig['xchan']; } diff --git a/include/diaspora.php b/include/diaspora.php index 736be4f08..22574f9f8 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -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(); diff --git a/include/network.php b/include/network.php index 224d9d5e1..a7127c1a2 100644 --- a/include/network.php +++ b/include/network.php @@ -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 = $m['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; +} |