OStatus: New fields in OStatus export/ Auto-tagging of replyed authors.

This commit is contained in:
Michael Vogel 2015-06-03 01:26:46 +02:00
parent 39d4856abb
commit b60677ef1b
2 changed files with 80 additions and 72 deletions

View file

@ -4346,21 +4346,6 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
else else
$body = $item['body']; $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; $htmlbody = $body;
if ($item['title'] != "") if ($item['title'] != "")
@ -4368,47 +4353,80 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7); $htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7);
$o .= '<id>' . xmlify($item['uri']) . '</id>' . "\r\n"; $o = "\r\n\r\n<entry>\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"; // OStatus stuff
$o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n"; $o .= "\t".'<id>' . xmlify($item['uri']) . '</id>'."\r\n";
$o .= '<dfrn:env>' . base64url_encode($body, true) . '</dfrn:env>' . "\r\n"; $o .= "\t".'<title>' . xmlify($item['title']) . '</title>'."\r\n";
$o .= '<content type="' . $type . '" >' . xmlify((($type === 'html') ? $htmlbody : $body)) . '</content>' . "\r\n"; $o .= "\t".'<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"; $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";
if($comment) if($comment)
$o .= '<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>' . "\r\n"; $o .= "\t".'<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>'."\r\n";
if($item['location']) { if($item['location']) {
$o .= '<dfrn:location>' . xmlify($item['location']) . '</dfrn:location>' . "\r\n"; $o .= "\t".'<dfrn:location>' . xmlify($item['location']) . '</dfrn:location>'."\r\n";
$o .= '<poco:address><poco:formatted>' . xmlify($item['location']) . '</poco:formatted></poco:address>' . "\r\n"; $o .= "\t".'<poco:address><poco:formatted>' . xmlify($item['location']) . '</poco:formatted></poco:address>'."\r\n";
} }
if($item['coord']) if($item['coord'])
$o .= '<georss:point>' . xmlify($item['coord']) . '</georss:point>' . "\r\n"; $o .= "\t".'<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'])) if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']))
$o .= '<dfrn:private>' . (($item['private']) ? $item['private'] : 1) . '</dfrn:private>' . "\r\n"; $o .= "\t".'<dfrn:private>' . (($item['private']) ? $item['private'] : 1) . '</dfrn:private>'."\r\n";
if($item['extid']) if($item['extid'])
$o .= '<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>' . "\r\n"; $o .= "\t".'<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>'."\r\n";
if($item['bookmark']) if($item['bookmark'])
$o .= '<dfrn:bookmark>true</dfrn:bookmark>' . "\r\n"; $o .= "\t".'<dfrn:bookmark>true</dfrn:bookmark>'."\r\n";
if($item['app']) if($item['app'])
$o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n"; $o .= "\t".'<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>'."\r\n";
if($item['guid']) if($item['guid'])
$o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n"; $o .= "\t".'<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>'."\r\n";
if($item['signed_text']) { if($item['signed_text']) {
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer']))); $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
$o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n"; $o .= "\t".'<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); $actobj = construct_activity_object($item);
if(strlen($actobj)) if(strlen($actobj))
$o .= $actobj; $o .= $actobj;
@ -4419,16 +4437,10 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$tags = item_getfeedtags($item); $tags = item_getfeedtags($item);
if(count($tags)) { if(count($tags)) {
foreach($tags as $t) { foreach($tags as $t) {
$o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n"; $o .= "\t".'<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); call_hooks('atom_entry', $o);
$o .= '</entry>'."\r\n"; $o .= '</entry>'."\r\n";

View file

@ -565,23 +565,19 @@ function item_post(&$a) {
$tags = get_tags($body); $tags = get_tags($body);
if($parent) {
/** /**
* add a statusnet style reply tag if the original post was from there * add a statusnet style reply tag if the original post was from there
* and we are replying, and there isn't one already * and we are replying, and there isn't one already
*/ */
if($parent AND ($parent_contact['network'] === NETWORK_OSTATUS)) {
if ($parent_contact['id'] != "") if ($parent_contact['id'] != "")
$contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id']; $contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id'];
//elseif ($parent_contact['addr'] != "")
// $contact = '@'.$parent_contact['addr'];
else else
$contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]'; $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]';
if (!in_array($contact,$tags)) { if (!in_array($contact,$tags)) {
if ($parent_contact['network'] === NETWORK_OSTATUS)
$body = $contact.' '.$body; $body = $contact.' '.$body;
$tags[] = $contact; $tags[] = $contact;
} }