Merge pull request #3697 from annando/new-ostatus
Rewritten OStatus inbound part
This commit is contained in:
commit
cf6874cffc
5
boot.php
5
boot.php
|
@ -229,8 +229,9 @@ define('PROTOCOL_UNKNOWN', 0);
|
|||
define('PROTOCOL_DFRN', 1);
|
||||
define('PROTOCOL_DIASPORA', 2);
|
||||
define('PROTOCOL_OSTATUS_SALMON', 3);
|
||||
define('PROTOCOL_OSTATUS_FEED', 4);
|
||||
define('PROTOCOL_GS_CONVERSATION', 5);
|
||||
define('PROTOCOL_OSTATUS_FEED', 4); // Deprecated
|
||||
define('PROTOCOL_GS_CONVERSATION', 5); // Deprecated
|
||||
define('PROTOCOL_SPLITTED_CONV', 6);
|
||||
/** @}*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,12 +42,6 @@ function cron_run(&$argv, &$argc){
|
|||
// Expire and remove user entries
|
||||
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
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ function cronjobs_run(&$argv, &$argc){
|
|||
global $a;
|
||||
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/ostatus.php';
|
||||
require_once 'include/post_update.php';
|
||||
require_once 'mod/nodeinfo.php';
|
||||
require_once 'include/photos.php';
|
||||
|
@ -22,19 +21,6 @@ function cronjobs_run(&$argv, &$argc){
|
|||
|
||||
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
|
||||
// see include/post_update.php for more details
|
||||
if ($argv[1] == 'post_update') {
|
||||
|
|
|
@ -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;
|
||||
|
@ -823,11 +820,12 @@ class dfrn {
|
|||
* @param array $owner Owner record
|
||||
* @param bool $comment Trigger the sending of the "comment" element
|
||||
* @param int $cid Contact ID of the recipient
|
||||
* @param bool $single If set, the entry is created as an XML document with a single "entry" element
|
||||
*
|
||||
* @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 +838,22 @@ class dfrn {
|
|||
return xml::create_element($doc, "at:deleted-entry", "", $attributes);
|
||||
}
|
||||
|
||||
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 +881,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);
|
||||
}
|
||||
|
|
|
@ -534,6 +534,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
}
|
||||
|
||||
// Converting the plink
|
||||
/// @todo Check if this is really still needed
|
||||
if ($arr['network'] == NETWORK_OSTATUS) {
|
||||
if (isset($arr['plink'])) {
|
||||
$arr['plink'] = ostatus::convert_href($arr['plink']);
|
||||
|
|
1442
include/ostatus.php
1442
include/ostatus.php
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
$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) {
|
||||
$alternate = System::baseUrl().'/display/'.$nick.'/'.$item_id.'.atom';
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue