+function statusnet_prepare_body(&$a,&$b) {
+ if ($b["item"]["network"] != NETWORK_STATUSNET)
+ return;
+
+ if ($b["preview"]) {
+ $max_char = get_pconfig(local_user(),'statusnet','max_char');
+ if (intval($max_char) == 0)
+ $max_char = 140;
+
+ require_once("include/plaintext.php");
+ $item = $b["item"];
+ $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+
+ $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick
+ FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1",
+ dbesc($item["thr-parent"]),
+ intval(local_user()));
+
+ if(count($r)) {
+ $orig_post = $r[0];
+ //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]";
+ //$nicknameplain = "@".$orig_post["contact_nick"];
+
+ $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
+
+ $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
+ $nicknameplain = "@".$nick;
+
+ if ((strpos($item["body"], $nickname) === false) AND (strpos($item["body"], $nicknameplain) === false))
+ $item["body"] = $nickname." ".$item["body"];
+ }
+
+
+ $msgarr = plaintext($a, $item, $max_char, true, 7);
+ $msg = $msgarr["text"];
+
+ if (isset($msgarr["url"]))
+ $msg .= " ".$msgarr["url"];
+
+ if (isset($msgarr["image"]))
+ $msg .= " ".$msgarr["image"];
+
+ $b['html'] = nl2br(htmlspecialchars($msg));
+ }
+}
+