+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;
+}