}
if (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND $contact['fetch_further_information']) {
- $res["body"] = $res["title"].add_page_info($res['plink']);
+ $res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2));
$res["title"] = "";
$res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
} elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
return $res;
}
-function add_page_info($url, $no_photos = false, $photo = "") {
- require_once("mod/parse_url.php");
-
- $data = parseurl_getsiteinfo($url, true);
-
- logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
+function add_page_info_data($data) {
+ call_hooks('page_info_data', $data);
// It maybe is a rich content, but if it does have everything that a link has,
// then treat it that way
return("");
if (($data["type"] != "photo") AND is_string($data["title"]))
- $text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]";
+ $text .= "[bookmark=".$data["url"]."]".trim($data["title"])."[/bookmark]";
if (($data["type"] != "video") AND ($photo != ""))
$text .= '[img]'.$photo.'[/img]';
if (($data["type"] != "photo") AND is_string($data["text"]))
$text .= "[quote]".$data["text"]."[/quote]";
- return("\n[class=type-".$data["type"]."]".$text."[/class]");
+ $hashtags = "";
+ if (isset($data["keywords"]) AND count($data["keywords"])) {
+ $a = get_app();
+ $hashtags = "\n";
+ foreach ($data["keywords"] AS $keyword) {
+ $hashtag = str_replace(" ", "", $keyword);
+ $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
+ }
+ }
+
+ return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags);
+}
+
+function add_page_info($url, $no_photos = false, $photo = "", $keywords = false) {
+ require_once("mod/parse_url.php");
+
+ $data = parseurl_getsiteinfo($url, true);
+
+ logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
+
+ if (!$keywords AND isset($data["keywords"]))
+ unset($data["keywords"]);
+
+ $text = add_page_info_data($data);
+
+ return($text);
}
function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
// This is my contact on another system, but it's really me.
// Turn this into a wall post.
- if($contact['remote_self']) {
- if ($contact['remote_self'] == 2) {
+ if($contact['remote_self'] AND (($contact['network'] === NETWORK_FEED) OR !$datarray['private'])) {
+ logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
+ if ($contact['remote_self'] == 1)
+ // Prevent that forwarded posts will be forwarded again
+ $notify = (normalise_link($datarray['author-link']) == normalise_link($datarray['owner-link']));
+ elseif ($contact['remote_self'] == 2) {
$r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid']));
if (count($r)) {
$datarray['contact-id'] = $r[0]["id"];
$datarray['author-link'] = $datarray['owner-link'];
$datarray['author-avatar'] = $datarray['owner-avatar'];
}
+ $notify = true;
}
if (!isset($datarray["app"]) OR ($datarray["app"] == ""))
$datarray["app"] = network_to_name($contact['network']);
- $notify = true;
- if($contact['network'] === NETWORK_FEED) {
+ if ($contact['network'] === NETWORK_FEED)
$datarray['private'] = 0;
+ elseif ($notify) {
+ $datarray2 = $datarray;
+
+ // Create a new guid and uri and post it as a forwarded post
+ $datarray2["guid"] = get_guid(32);
+ $datarray2["uri"] = item_new_uri($a->get_hostname(),$importer['uid']);
+ $datarray2["parent-uri"] = $datarray2["uri"];
+ $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid']));
+ if (count($r)) {
+ $datarray2['contact-id'] = $r[0]["id"];
+
+ $datarray2['owner-name'] = $r[0]["name"];
+ $datarray2['owner-link'] = $r[0]["url"];
+ $datarray2['owner-avatar'] = $r[0]["photo"];
+ }
+
+ // Store the forwarded post
+ $r = item_store($datarray2, false, true);
+ logger('remote-self forwarded post - Contact '.$contact['url'].' return '.$r.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
+
+ // Let the original item just be a regular item
+ $notify = false;
}
} else
$notify = false;
$r = item_store($datarray, false, $notify);
+ logger('Stored - Contact '.$contact['url'].' Notify '.$notify.' return '.$r.' Item '.print_r($datarray, true), LOGGER_DEBUG);
continue;
}
// This is my contact on another system, but it's really me.
// Turn this into a wall post.
- if($importer['remote_self']) {
- if ($importer['remote_self'] == 2) {
+ if($importer['remote_self'] AND (($importer['network'] === NETWORK_FEED) OR !$datarray['private'])) {
+ logger('remote-self start - Contact '.$importer['url'].' - '.$importer['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
+ if ($importer['remote_self'] == 1)
+ // Prevent that forwarded posts will be forwarded again
+ $notify = (normalise_link($datarray['author-link']) == normalise_link($datarray['owner-link']));
+ elseif ($importer['remote_self'] == 2) {
$r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`",
intval($importer['importer_uid']));
if (count($r)) {
$datarray['author-link'] = $datarray['owner-link'];
$datarray['author-avatar'] = $datarray['owner-avatar'];
}
+ $notify = true;
}
- $notify = true;
+ if (!isset($datarray["app"]) OR ($datarray["app"] == ""))
+ $datarray["app"] = network_to_name($importer['network']);
+
+ if ($importer['network'] === NETWORK_FEED)
+ $datarray['private'] = 0;
+ elseif ($notify) {
+ $datarray2 = $datarray;
+ // Create a new guid and uri and post it as a forwarded post
+ $datarray2["guid"] = get_guid(32);
+ $datarray2["uri"] = item_new_uri($a->get_hostname(),$importer['uid']);
+ $datarray2["parent-uri"] = $datarray2["uri"];
+ $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid']));
+ if (count($r)) {
+ $datarray2['contact-id'] = $r[0]["id"];
+
+ $datarray2['owner-name'] = $r[0]["name"];
+ $datarray2['owner-link'] = $r[0]["url"];
+ $datarray2['owner-avatar'] = $r[0]["photo"];
+ }
+
+ // Store the forwarded post
+ $r = item_store($datarray2, false, true);
+ logger('remote-self forwarded post - Contact '.$importer['url'].' return '.$r.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
+
+ // Let the original item just be a regular item
+ $notify = false;
+ }
} else
$notify = false;