From b60677ef1ba22be759a6a582e97c3e33ab6773ed Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 3 Jun 2015 01:26:46 +0200 Subject: [PATCH] OStatus: New fields in OStatus export/ Auto-tagging of replyed authors. --- include/items.php | 120 +++++++++++++++++++++++++--------------------- mod/item.php | 16 +++---- 2 files changed, 72 insertions(+), 64 deletions(-) diff --git a/include/items.php b/include/items.php index 588bd353f7..809d9dcd6d 100644 --- a/include/items.php +++ b/include/items.php @@ -208,7 +208,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, call_hooks('atom_feed_end', $atom); - $atom .= '' . "\r\n"; + $atom .= ''."\r\n"; return $atom; } @@ -235,7 +235,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, call_hooks('atom_feed_end', $atom); - $atom .= '' . "\r\n"; + $atom .= ''."\r\n"; return $atom; } @@ -250,18 +250,18 @@ function construct_verb($item) { function construct_activity_object($item) { if($item['object']) { - $o = '' . "\r\n"; + $o = ''."\r\n"; $r = parse_xml_string($item['object'],false); if(! $r) return ''; if($r->type) - $o .= '' . xmlify($r->type) . '' . "\r\n"; + $o .= '' . xmlify($r->type) . ''."\r\n"; if($r->id) - $o .= '' . xmlify($r->id) . '' . "\r\n"; + $o .= '' . xmlify($r->id) . ''."\r\n"; if($r->title) - $o .= '' . xmlify($r->title) . '' . "\r\n"; + $o .= '' . xmlify($r->title) . ''."\r\n"; if($r->link) { if(substr($r->link,0,1) === '<') { // patch up some facebook "like" activity objects that got stored incorrectly @@ -273,11 +273,11 @@ function construct_activity_object($item) { $o .= $r->link; } else - $o .= '' . "\r\n"; + $o .= ''."\r\n"; } if($r->content) - $o .= '' . xmlify(bbcode($r->content)) . '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= '' . xmlify(bbcode($r->content)) . ''."\r\n"; + $o .= ''."\r\n"; return $o; } @@ -287,16 +287,16 @@ function construct_activity_object($item) { function construct_activity_target($item) { if($item['target']) { - $o = '' . "\r\n"; + $o = ''."\r\n"; $r = parse_xml_string($item['target'],false); if(! $r) return ''; if($r->type) - $o .= '' . xmlify($r->type) . '' . "\r\n"; + $o .= '' . xmlify($r->type) . ''."\r\n"; if($r->id) - $o .= '' . xmlify($r->id) . '' . "\r\n"; + $o .= '' . xmlify($r->id) . ''."\r\n"; if($r->title) - $o .= '' . xmlify($r->title) . '' . "\r\n"; + $o .= '' . xmlify($r->title) . ''."\r\n"; if($r->link) { if(substr($r->link,0,1) === '<') { if(strstr($r->link,'&') && (! strstr($r->link,'&'))) @@ -305,11 +305,11 @@ function construct_activity_target($item) { $o .= $r->link; } else - $o .= '' . "\r\n"; + $o .= ''."\r\n"; } if($r->content) - $o .= '' . xmlify(bbcode($r->content)) . '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= '' . xmlify(bbcode($r->content)) . ''."\r\n"; + $o .= ''."\r\n"; return $o; } @@ -4321,8 +4321,8 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) { $o .= "<$tag>\r\n"; $o .= "$name\r\n"; $o .= "$uri\r\n"; - $o .= '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= ''."\r\n"; + $o .= ''."\r\n"; call_hooks('atom_author', $o); @@ -4338,7 +4338,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { return; if($item['deleted']) - return '' . "\r\n"; + return ''."\r\n"; if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) @@ -4346,69 +4346,87 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { else $body = $item['body']; + $htmlbody = $body; + + if ($item['title'] != "") + $htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody; + + $htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7); $o = "\r\n\r\n\r\n"; + // OStatus stuff + $o .= "\t".'' . xmlify($item['uri']) . ''."\r\n"; + $o .= "\t".'' . xmlify($item['title']) . ''."\r\n"; + $o .= "\t".'' . xmlify((($type === 'html') ? $htmlbody : $body)) . ''."\r\n"; + $o .= "\t".''."\r\n"; + + $verb = construct_verb($item); + $o .= "\t".''.xmlify($verb).''."\r\n"; + $o .= "\t".'' . xmlify($verb) . ''."\r\n"; + + $o .= "\t".'' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . ''."\r\n"; + $o .= "\t".'' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . ''."\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 .= '' . "\r\n"; + $o .= "\t".''."\r\n"; + $o .= "\t".''."\r\n"; } - $htmlbody = $body; + $o .= "\t".''."\r\n"; - if ($item['title'] != "") - $htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody; + $o .= item_getfeedattach($item); - $htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7); + $mentioned = get_mentions($item); + if($mentioned) + $o .= $mentioned; + + $o .= "\t".''."\r\n"; + $o .= "\t".''."\r\n"; + $o .= "\t".''."\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 .= '' . xmlify($item['uri']) . '' . "\r\n"; - $o .= '' . xmlify($item['title']) . '' . "\r\n"; - $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; - $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; - $o .= '' . base64url_encode($body, true) . '' . "\r\n"; - $o .= '' . xmlify((($type === 'html') ? $htmlbody : $body)) . '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= "\t".'' . base64url_encode($body, true) . ''."\r\n"; if($comment) - $o .= '' . intval($item['last-child']) . '' . "\r\n"; + $o .= "\t".'' . intval($item['last-child']) . ''."\r\n"; if($item['location']) { - $o .= '' . xmlify($item['location']) . '' . "\r\n"; - $o .= '' . xmlify($item['location']) . '' . "\r\n"; + $o .= "\t".'' . xmlify($item['location']) . ''."\r\n"; + $o .= "\t".'' . xmlify($item['location']) . ''."\r\n"; } if($item['coord']) - $o .= '' . xmlify($item['coord']) . '' . "\r\n"; + $o .= "\t".'' . xmlify($item['coord']) . ''."\r\n"; if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) - $o .= '' . (($item['private']) ? $item['private'] : 1) . '' . "\r\n"; + $o .= "\t".'' . (($item['private']) ? $item['private'] : 1) . ''."\r\n"; if($item['extid']) - $o .= '' . xmlify($item['extid']) . '' . "\r\n"; + $o .= "\t".'' . xmlify($item['extid']) . ''."\r\n"; if($item['bookmark']) - $o .= 'true' . "\r\n"; + $o .= "\t".'true'."\r\n"; if($item['app']) - $o .= '' . "\r\n"; + $o .= "\t".''."\r\n"; if($item['guid']) - $o .= '' . $item['guid'] . '' . "\r\n"; + $o .= "\t".'' . $item['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 .= '' . xmlify($sign) . '' . "\r\n"; + $o .= "\t".'' . xmlify($sign) . ''."\r\n"; } - $verb = construct_verb($item); - $o .= '' . xmlify($verb) . '' . "\r\n"; $actobj = construct_activity_object($item); if(strlen($actobj)) $o .= $actobj; @@ -4419,19 +4437,13 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $tags = item_getfeedtags($item); if(count($tags)) { foreach($tags as $t) { - $o .= '' . "\r\n"; + $o .= "\t".''."\r\n"; } } - $o .= item_getfeedattach($item); - - $mentioned = get_mentions($item); - if($mentioned) - $o .= $mentioned; - call_hooks('atom_entry', $o); - $o .= '' . "\r\n"; + $o .= ''."\r\n"; return $o; } @@ -4613,7 +4625,7 @@ function item_getfeedattach($item) { $ret .= 'length="' . intval($matches[2]) . '" '; if($matches[4] !== ' ') $ret .= 'title="' . xmlify(trim($matches[4])) . '" '; - $ret .= ' />' . "\r\n"; + $ret .= ' />'."\r\n"; } } } diff --git a/mod/item.php b/mod/item.php index 45b86c3100..093316dbee 100644 --- a/mod/item.php +++ b/mod/item.php @@ -565,23 +565,19 @@ function item_post(&$a) { $tags = get_tags($body); - if($parent) { - /** - * add a statusnet style reply tag if the original post was from there - * and we are replying, and there isn't one already - */ + /** + * add a statusnet style reply tag if the original post was from there + * and we are replying, and there isn't one already + */ + if($parent AND ($parent_contact['network'] === NETWORK_OSTATUS)) { if ($parent_contact['id'] != "") $contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id']; - //elseif ($parent_contact['addr'] != "") - // $contact = '@'.$parent_contact['addr']; else $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]'; if (!in_array($contact,$tags)) { - if ($parent_contact['network'] === NETWORK_OSTATUS) - $body = $contact.' '.$body; - + $body = $contact.' '.$body; $tags[] = $contact; } -- 2.39.5