New routines are now enabled

This commit is contained in:
Michael Vogel 2016-01-23 02:44:30 +01:00
parent 1406d7cbec
commit 444b417de0
4 changed files with 70 additions and 14 deletions

View file

@ -5,6 +5,7 @@ require_once('include/html2plain.php');
require_once("include/Scrape.php"); require_once("include/Scrape.php");
require_once('include/diaspora.php'); require_once('include/diaspora.php');
require_once("include/ostatus.php"); require_once("include/ostatus.php");
require_once("include/dfrn.php");
function delivery_run(&$argv, &$argc){ function delivery_run(&$argv, &$argc){
global $a, $db; global $a, $db;
@ -278,6 +279,53 @@ function delivery_run(&$argv, &$argc){
case NETWORK_DFRN: case NETWORK_DFRN:
logger('notifier: '.$target_item["guid"].' dfrndelivery: ' . $contact['name']); logger('notifier: '.$target_item["guid"].' dfrndelivery: ' . $contact['name']);
if ($mail) {
$item["body"] = $body;
$atom = dfrn_mail($item, $owner);
} elseif ($fsuggest) {
$atom = dfrn_fsuggest($item, $owner);
// q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id'])
} elseif ($relocate)
$atom = dfrn_relocate($owner, $uid);
elseif($followup) {
$msgitems = array();
foreach($items as $item) { // there is only one item
if(!$item['parent'])
continue;
if($item['id'] == $item_id) {
logger('followup: item: ' . print_r($item,true), LOGGER_DATA);
$msgitems[] = $item;
}
}
$atom = dfrn_entries($msgitems,$owner);
} else {
$msgitems = array();
foreach($items as $item) {
if(!$item['parent'])
continue;
// private emails may be in included in public conversations. Filter them.
if(($public_message) && $item['private'])
continue;
$item_contact = get_item_contact($item,$icontacts);
if(!$item_contact)
continue;
if($normal_mode) {
if($item_id == $item['id'] || $item['id'] == $item['parent']) {
$item["entry:comment-allow"] = true;
$item["entry:cid"] = (($top_level) ? $contact['id'] : 0);
$msgitems[] = $item;
}
} else {
$item["entry:comment-allow"] = true;
$msgitems[] = $item;
}
}
$atom = dfrn_entries($msgitems,$owner);
}
/*
$feed_template = get_markup_template('atom_feed.tpl'); $feed_template = get_markup_template('atom_feed.tpl');
$mail_template = get_markup_template('atom_mail.tpl'); $mail_template = get_markup_template('atom_mail.tpl');
@ -345,7 +393,7 @@ function delivery_run(&$argv, &$argc){
$sugg_template = get_markup_template('atom_relocate.tpl'); $sugg_template = get_markup_template('atom_relocate.tpl');
/* get site pubkey. this could be a new installation with no site keys*/ // get site pubkey. this could be a new installation with no site keys
$pubkey = get_config('system','site_pubkey'); $pubkey = get_config('system','site_pubkey');
if(! $pubkey) { if(! $pubkey) {
$res = new_keypair(1024); $res = new_keypair(1024);
@ -408,8 +456,8 @@ function delivery_run(&$argv, &$argc){
} }
$atom .= '</feed>' . "\r\n"; $atom .= '</feed>' . "\r\n";
*/
logger('notifier: '.$contact["url"].' '.$target_item["guid"].' entry: '.$atom, LOGGER_DEBUG); logger('notifier entry: '.$contact["url"].' '.$target_item["guid"].' entry: '.$atom, LOGGER_DEBUG);
logger('notifier: ' . $atom, LOGGER_DATA); logger('notifier: ' . $atom, LOGGER_DATA);
$basepath = implode('/', array_slice(explode('/',$contact['url']),0,3)); $basepath = implode('/', array_slice(explode('/',$contact['url']),0,3));

View file

@ -191,7 +191,12 @@ function dfrn_feed(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
if(isset($category)) if(isset($category))
$alternatelink .= "/category/".$category; $alternatelink .= "/category/".$category;
$root = dfrn_add_header($doc, $owner, "author", $alternatelink, true); if ($public_feed)
$author = "dfrn:owner";
else
$author = "author";
$root = dfrn_add_header($doc, $owner, $author, $alternatelink, true);
// This hook can't work anymore // This hook can't work anymore
// call_hooks('atom_feed', $atom); // call_hooks('atom_feed', $atom);
@ -622,14 +627,13 @@ function dfrn_entry($doc, $type, $item, $owner, $comment = false, $cid = 0) {
if(!$item['parent']) if(!$item['parent'])
return; return;
$entry = $doc->createElement("entry");
if($item['deleted']) { if($item['deleted']) {
$attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)); $attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME));
xml_add_element($doc, $entry, "at:deleted-entry", "", $attributes); return xml_create_element($doc, "at:deleted-entry", "", $attributes);
return $entry;
} }
$entry = $doc->createElement("entry");
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);
else else

View file

@ -1121,7 +1121,7 @@ function get_reshared_guid($item) {
return $guid; return $guid;
} }
function xml_add_element($doc, $parent, $element, $value = "", $attributes = array()) { function xml_create_element($doc, $element, $value = "", $attributes = array()) {
$element = $doc->createElement($element, xmlify($value)); $element = $doc->createElement($element, xmlify($value));
foreach ($attributes AS $key => $value) { foreach ($attributes AS $key => $value) {
@ -1129,7 +1129,11 @@ function xml_add_element($doc, $parent, $element, $value = "", $attributes = arr
$attribute->value = xmlify($value); $attribute->value = xmlify($value);
$element->appendChild($attribute); $element->appendChild($attribute);
} }
return $element;
}
function xml_add_element($doc, $parent, $element, $value = "", $attributes = array()) {
$element = xml_create_element($doc, $element, $value, $attributes);
$parent->appendChild($element); $parent->appendChild($element);
} }

View file

@ -1,9 +1,7 @@
<?php <?php
require_once('include/items.php'); require_once('include/items.php');
require_once('include/auth.php'); require_once('include/auth.php');
require_once('include/dfrn.php');
function dfrn_poll_init(&$a) { function dfrn_poll_init(&$a) {
@ -46,7 +44,8 @@ function dfrn_poll_init(&$a) {
logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user); logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user);
header("Content-type: application/atom+xml"); header("Content-type: application/atom+xml");
echo get_feed_for($a, '', $user,$last_update); //echo get_feed_for($a, '', $user,$last_update);
echo dfrn_feed($a, '', $user,$last_update);
killme(); killme();
} }
@ -373,7 +372,8 @@ function dfrn_poll_post(&$a) {
} }
header("Content-type: application/atom+xml"); header("Content-type: application/atom+xml");
$o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction); //$o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
$o = dfrn_feed($a,$dfrn_id, $a->argv[1], $last_update, $direction);
echo $o; echo $o;
killme(); killme();