return false;
}
+function diaspora_plink($addr, $guid) {
+ $r = q("SELECT `url`, `nick` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", $addr);
+
+ // Fallback
+ if (!$r)
+ return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
+
+ if (strstr($r[0]["url"], "/channel/"))
+ return $r[0]["url"]."/?f=&mid=".$guid;
+
+ return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
+}
function diaspora_post($importer,$xml,$msg) {
}
}
- $plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
+ $plink = diaspora_plink($diaspora_handle, $guid);
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['private'] = $private;
$datarray['parent'] = 0;
- $datarray['plink'] = 'https://'.substr($author,strpos($author,'@')+1).'/posts/'.$guid;
+ $datarray['plink'] = diaspora_plink($author, $guid);
$datarray['author-name'] = $person['name'];
$datarray['author-link'] = $person['url'];
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$datarray = array();
- $plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
+ $plink = diaspora_plink($diaspora_handle, $guid);
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray2['guid'] = $orig_guid;
$datarray2['uri'] = $datarray2['parent-uri'] = $orig_author.':'.$orig_guid;
$datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = $datarray2['commented'] = $datarray2['received'] = datetime_convert('UTC','UTC',$orig_created);
- $datarray2['plink'] = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
+ $datarray2['plink'] = diaspora_plink($orig_author, $orig_guid);
$datarray2['author-name'] = $person['name'];
$datarray2['author-link'] = $person['url'];
return;
}
- $plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
+ $plink = diaspora_plink($diaspora_handle, $guid);
$datarray = array();