OStatus: Reworked import

This commit is contained in:
Michael 2017-09-10 07:21:23 +00:00
commit 4b403e4fe2
5 changed files with 532 additions and 1143 deletions

View file

@ -303,7 +303,7 @@ class dfrn {
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE `item`.`id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
AND `item`.`wall` AND NOT `item`.`private`",
AND NOT `item`.`private`",
intval($item_id)
);
@ -330,12 +330,9 @@ class dfrn {
$alternatelink = $owner['url'];
$root = self::add_header($doc, $owner, 'dfrn:owner', $alternatelink, true);
$type = 'html';
$entry = self::entry($doc, $type, $item, $owner, true);
$root->appendChild($entry);
$root = self::entry($doc, $type, $item, $owner, true, 0, true);
$atom = trim($doc->saveXML());
return $atom;
@ -827,7 +824,7 @@ class dfrn {
* @return object XML entry object
* @todo Add type-hints
*/
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0) {
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false) {
$mentioned = array();
@ -840,7 +837,22 @@ class dfrn {
return xml::create_element($doc, "at:deleted-entry", "", $attributes);
}
$entry = $doc->createElement("entry");
if (!$single) {
$entry = $doc->createElement("entry");
} else {
$entry = $doc->createElementNS(NAMESPACE_ATOM1, 'entry');
$doc->appendChild($entry);
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
$entry->setAttribute("xmlns:at", NAMESPACE_TOMB);
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
$entry->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
}
if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
$body = fix_private_photos($item['body'],$owner['uid'],$item,$cid);
@ -868,10 +880,10 @@ class dfrn {
$entry->appendChild($dfrnowner);
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$parent = q("SELECT `guid`,`plink` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", dbesc($parent_item), intval($item['uid']));
$attributes = array("ref" => $parent_item, "type" => "text/html",
"href" => System::baseUrl().'/display/'.$parent[0]['guid'],
"href" => $parent[0]['plink'],
"dfrn:diaspora_guid" => $parent[0]['guid']);
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
}