Removed bad plink detection.
This commit is contained in:
parent
c416ce4893
commit
ba36910343
2 changed files with 65 additions and 101 deletions
|
@ -894,9 +894,9 @@ function get_atom_elements($feed, $item, $contact = array()) {
|
|||
if ($conversation["rel"] == "ostatus:conversation") {
|
||||
$res["ostatus_conversation"] = ostatus_convert_href($conversation["href"]);
|
||||
logger('get_atom_elements: found conversation url '.$res["ostatus_conversation"]);
|
||||
} elseif ($conversation["rel"] == "alternate") {
|
||||
$res["plink"] = $conversation["href"];
|
||||
logger('get_atom_elements: found plink '.$res["plink"]);
|
||||
//} elseif ($conversation["rel"] == "alternate") {
|
||||
// $res["plink"] = $conversation["href"];
|
||||
// logger('get_atom_elements: found plink '.$res["plink"]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1187,18 +1187,6 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
}
|
||||
}
|
||||
|
||||
// If there is no guid then take the same guid that was taken before for the same plink
|
||||
if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "") AND (trim($arr['network']) != "")) {
|
||||
logger('item_store: checking for an existing guid for plink '.$arr['plink'], LOGGER_DEBUG);
|
||||
$r = q("SELECT `guid` FROM `guid` WHERE `plink` = '%s' AND `network` = '%s' LIMIT 1",
|
||||
dbesc(trim($arr['plink'])), dbesc(trim($arr['network'])));
|
||||
|
||||
if(count($r)) {
|
||||
$arr['guid'] = $r[0]["guid"];
|
||||
logger('item_store: found guid '.$arr['guid'].' for plink '.$arr['plink'], LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
// Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
|
||||
// Deactivated, since the bbcode parser can handle with it - and it destroys posts with some smileys that contain "<"
|
||||
//if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
|
||||
|
@ -1415,16 +1403,6 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
|||
return 0;
|
||||
}
|
||||
|
||||
$r = q("SELECT `id` FROM `item` WHERE `plink` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($arr['plink']),
|
||||
dbesc($arr['network']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if($r && count($r)) {
|
||||
logger('duplicated item with the same plink found. ' . print_r($arr,true));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check for an existing post with the same content. There seems to be a problem with OStatus.
|
||||
$r = q("SELECT `id` FROM `item` WHERE `body` = '%s' AND `network` = '%s' AND `created` = '%s' AND `contact-id` = %d AND `uid` = %d LIMIT 1",
|
||||
dbesc($arr['body']),
|
||||
|
@ -4346,6 +4324,21 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
|||
else
|
||||
$body = $item['body'];
|
||||
|
||||
|
||||
$o = "\r\n\r\n<entry>\r\n";
|
||||
|
||||
if(is_array($author))
|
||||
$o .= atom_author('author',$author['name'],$author['url'],80,80,$author['thumb']);
|
||||
else
|
||||
$o .= atom_author('author',(($item['author-name']) ? $item['author-name'] : $item['name']),(($item['author-link']) ? $item['author-link'] : $item['url']),80,80,(($item['author-avatar']) ? $item['author-avatar'] : $item['thumb']));
|
||||
if(strlen($item['owner-name']))
|
||||
$o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']);
|
||||
|
||||
if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
|
||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||
$o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />' . "\r\n";
|
||||
}
|
||||
|
||||
$htmlbody = $body;
|
||||
|
||||
if ($item['title'] != "")
|
||||
|
@ -4353,80 +4346,47 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
|||
|
||||
$htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7);
|
||||
|
||||
$o = "\r\n\r\n<entry>\r\n";
|
||||
|
||||
// OStatus stuff
|
||||
$o .= "\t".'<id>' . xmlify($item['uri']) . '</id>'."\r\n";
|
||||
$o .= "\t".'<title>' . xmlify($item['title']) . '</title>'."\r\n";
|
||||
$o .= "\t".'<content type="' . $type . '" >' . xmlify((($type === 'html') ? $htmlbody : $body)) . '</content>'."\r\n";
|
||||
$o .= "\t".'<link rel="alternate" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']) . '" />'."\r\n";
|
||||
|
||||
$verb = construct_verb($item);
|
||||
$o .= "\t".'<activity:verb>'.xmlify($verb).'</activity:verb>'."\r\n";
|
||||
$o .= "\t".'<as:verb>' . xmlify($verb) . '</as:verb>'."\r\n";
|
||||
|
||||
$o .= "\t".'<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>'."\r\n";
|
||||
$o .= "\t".'<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>'."\r\n";
|
||||
if(is_array($author))
|
||||
$o .= atom_author('author',$author['name'],$author['url'],80,80,$author['thumb']);
|
||||
else
|
||||
$o .= atom_author('author',(($item['author-name']) ? $item['author-name'] : $item['name']),(($item['author-link']) ? $item['author-link'] : $item['url']),80,80,(($item['author-avatar']) ? $item['author-avatar'] : $item['thumb']));
|
||||
|
||||
if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
|
||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||
$o .= "\t".'<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />'."\r\n";
|
||||
$o .= "\t".'<link rel="related" href="'.xmlify($a->get_baseurl().'/display/'.$owner['nickname'].'/'.$item['parent']).'"/>'."\r\n";
|
||||
}
|
||||
|
||||
$o .= "\t".'<link rel="ostatus:conversation" href="'.xmlify($a->get_baseurl().'/display/'.$owner['nickname'].'/'.$item['parent']).'"/>'."\r\n";
|
||||
|
||||
$o .= item_getfeedattach($item);
|
||||
|
||||
$mentioned = get_mentions($item);
|
||||
if($mentioned)
|
||||
$o .= $mentioned;
|
||||
|
||||
$o .= "\t".'<link rel="self" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
|
||||
$o .= "\t".'<link rel="edit" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
|
||||
$o .= "\t".'<statusnet:notice_info local_id="'.$item['id'].'" source="'.$item['app'].'"></statusnet:notice_info>'."\r\n";
|
||||
|
||||
// DFRN stuff
|
||||
if(strlen($item['owner-name']))
|
||||
$o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']);
|
||||
|
||||
$o .= "\t".'<dfrn:env>' . base64url_encode($body, true) . '</dfrn:env>'."\r\n";
|
||||
$o .= '<id>' . xmlify($item['uri']) . '</id>' . "\r\n";
|
||||
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
|
||||
$o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n";
|
||||
$o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n";
|
||||
$o .= '<dfrn:env>' . base64url_encode($body, true) . '</dfrn:env>' . "\r\n";
|
||||
$o .= '<content type="' . $type . '" >' . xmlify((($type === 'html') ? $htmlbody : $body)) . '</content>' . "\r\n";
|
||||
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']) . '" />' . "\r\n";
|
||||
|
||||
|
||||
if($comment)
|
||||
$o .= "\t".'<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>'."\r\n";
|
||||
$o .= '<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>' . "\r\n";
|
||||
|
||||
if($item['location']) {
|
||||
$o .= "\t".'<dfrn:location>' . xmlify($item['location']) . '</dfrn:location>'."\r\n";
|
||||
$o .= "\t".'<poco:address><poco:formatted>' . xmlify($item['location']) . '</poco:formatted></poco:address>'."\r\n";
|
||||
$o .= '<dfrn:location>' . xmlify($item['location']) . '</dfrn:location>' . "\r\n";
|
||||
$o .= '<poco:address><poco:formatted>' . xmlify($item['location']) . '</poco:formatted></poco:address>' . "\r\n";
|
||||
}
|
||||
|
||||
if($item['coord'])
|
||||
$o .= "\t".'<georss:point>' . xmlify($item['coord']) . '</georss:point>'."\r\n";
|
||||
$o .= '<georss:point>' . xmlify($item['coord']) . '</georss:point>' . "\r\n";
|
||||
|
||||
if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']))
|
||||
$o .= "\t".'<dfrn:private>' . (($item['private']) ? $item['private'] : 1) . '</dfrn:private>'."\r\n";
|
||||
$o .= '<dfrn:private>' . (($item['private']) ? $item['private'] : 1) . '</dfrn:private>' . "\r\n";
|
||||
|
||||
if($item['extid'])
|
||||
$o .= "\t".'<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>'."\r\n";
|
||||
$o .= '<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>' . "\r\n";
|
||||
if($item['bookmark'])
|
||||
$o .= "\t".'<dfrn:bookmark>true</dfrn:bookmark>'."\r\n";
|
||||
$o .= '<dfrn:bookmark>true</dfrn:bookmark>' . "\r\n";
|
||||
|
||||
if($item['app'])
|
||||
$o .= "\t".'<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>'."\r\n";
|
||||
$o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
|
||||
|
||||
if($item['guid'])
|
||||
$o .= "\t".'<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>'."\r\n";
|
||||
$o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n";
|
||||
|
||||
if($item['signed_text']) {
|
||||
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
|
||||
$o .= "\t".'<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>'."\r\n";
|
||||
$o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n";
|
||||
}
|
||||
|
||||
$verb = construct_verb($item);
|
||||
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
|
||||
$actobj = construct_activity_object($item);
|
||||
if(strlen($actobj))
|
||||
$o .= $actobj;
|
||||
|
@ -4437,10 +4397,16 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
|||
$tags = item_getfeedtags($item);
|
||||
if(count($tags)) {
|
||||
foreach($tags as $t) {
|
||||
$o .= "\t".'<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />'."\r\n";
|
||||
$o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$o .= item_getfeedattach($item);
|
||||
|
||||
$mentioned = get_mentions($item);
|
||||
if($mentioned)
|
||||
$o .= $mentioned;
|
||||
|
||||
call_hooks('atom_entry', $o);
|
||||
|
||||
$o .= '</entry>' . "\r\n";
|
||||
|
|
|
@ -594,8 +594,6 @@ function item_post(&$a) {
|
|||
|
||||
if (!in_array($toplevel_contact,$tags))
|
||||
$tags[] = $toplevel_contact;
|
||||
|
||||
logger("OStatus tags ".print_r($tags, true), LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$tagged = array();
|
||||
|
|
Loading…
Reference in a new issue