OStatus: Reworked import

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

View file

@ -42,12 +42,6 @@ function cron_run(&$argv, &$argc){
// Expire and remove user entries // Expire and remove user entries
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "expire_and_remove_users"); proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "expire_and_remove_users");
// Check OStatus conversations
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
// Check every conversation
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
// Call possible post update functions // Call possible post update functions
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update"); proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");

View file

@ -8,7 +8,6 @@ function cronjobs_run(&$argv, &$argc){
global $a; global $a;
require_once 'include/datetime.php'; require_once 'include/datetime.php';
require_once 'include/ostatus.php';
require_once 'include/post_update.php'; require_once 'include/post_update.php';
require_once 'mod/nodeinfo.php'; require_once 'mod/nodeinfo.php';
require_once 'include/photos.php'; require_once 'include/photos.php';
@ -22,19 +21,6 @@ function cronjobs_run(&$argv, &$argc){
logger("Starting cronjob ".$argv[1], LOGGER_DEBUG); logger("Starting cronjob ".$argv[1], LOGGER_DEBUG);
// Check OStatus conversations
// Check only conversations with mentions (for a longer time)
if ($argv[1] == 'ostatus_mentions') {
ostatus::check_conversations(true);
return;
}
// Check every conversation
if ($argv[1] == 'ostatus_conversations') {
ostatus::check_conversations(false);
return;
}
// Call possible post update functions // Call possible post update functions
// see include/post_update.php for more details // see include/post_update.php for more details
if ($argv[1] == 'post_update') { if ($argv[1] == 'post_update') {

View file

@ -303,7 +303,7 @@ class dfrn {
AND (NOT `contact`.`blocked` OR `contact`.`pending`) AND (NOT `contact`.`blocked` OR `contact`.`pending`)
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE `item`.`id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0 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) intval($item_id)
); );
@ -330,12 +330,9 @@ class dfrn {
$alternatelink = $owner['url']; $alternatelink = $owner['url'];
$root = self::add_header($doc, $owner, 'dfrn:owner', $alternatelink, true);
$type = 'html'; $type = 'html';
$entry = self::entry($doc, $type, $item, $owner, true); $root = self::entry($doc, $type, $item, $owner, true, 0, true);
$root->appendChild($entry);
$atom = trim($doc->saveXML()); $atom = trim($doc->saveXML());
return $atom; return $atom;
@ -827,7 +824,7 @@ class dfrn {
* @return object XML entry object * @return object XML entry object
* @todo Add type-hints * @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(); $mentioned = array();
@ -840,7 +837,22 @@ class dfrn {
return xml::create_element($doc, "at:deleted-entry", "", $attributes); return xml::create_element($doc, "at:deleted-entry", "", $attributes);
} }
if (!$single) {
$entry = $doc->createElement("entry"); $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']) { if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
$body = fix_private_photos($item['body'],$owner['uid'],$item,$cid); $body = fix_private_photos($item['body'],$owner['uid'],$item,$cid);
@ -868,10 +880,10 @@ class dfrn {
$entry->appendChild($dfrnowner); $entry->appendChild($dfrnowner);
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) { 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_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", $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']); "dfrn:diaspora_guid" => $parent[0]['guid']);
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes); xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
} }

File diff suppressed because it is too large Load diff

View file

@ -293,7 +293,7 @@ function display_content(App $a, $update = 0) {
} }
// We are displaying an "alternate" link if that post was public. See issue 2864 // We are displaying an "alternate" link if that post was public. See issue 2864
$is_public = dba::exists('item', array('id' => $item_id, 'private' => false, 'wall' => true)); $is_public = dba::exists('item', array('id' => $item_id, 'private' => false));
if ($is_public) { if ($is_public) {
$alternate = System::baseUrl().'/display/'.$nick.'/'.$item_id.'.atom'; $alternate = System::baseUrl().'/display/'.$nick.'/'.$item_id.'.atom';
} else { } else {