<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Core\Config;
+use Friendica\Database\DBM;
+use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\DFRN;
-require_once("boot.php");
-require_once('include/queue_fn.php');
-require_once('include/html2plain.php');
-require_once("include/Scrape.php");
-require_once('include/diaspora.php');
-require_once("include/ostatus.php");
-require_once("include/dfrn.php");
+require_once 'include/queue_fn.php';
+require_once 'include/html2plain.php';
+require_once 'include/ostatus.php';
function delivery_run(&$argv, &$argc){
- global $a, $db;
+ global $a;
- if (is_null($a)) {
- $a = new App;
- }
-
- if (is_null($db)) {
- @include(".htconfig.php");
- require_once("include/dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
- }
-
- require_once("include/session.php");
- require_once("include/datetime.php");
- require_once('include/items.php');
- require_once('include/bbcode.php');
- require_once('include/email.php');
-
- Config::load();
-
- load_hooks();
+ require_once 'include/datetime.php';
+ require_once 'include/items.php';
+ require_once 'include/bbcode.php';
+ require_once 'include/email.php';
if ($argc < 3) {
return;
}
- $a->set_baseurl(get_config('system','url'));
-
logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
$cmd = $argv[1];
$contact_id = intval($argv[$x]);
- /// @todo When switching completely to the worker we won't need this anymore
- // Some other process may have delivered this item already.
-
- $r = q("SELECT * FROM `deliverq` WHERE `cmd` = '%s' AND `item` = %d AND `contact` = %d LIMIT 1",
- dbesc($cmd),
- dbesc($item_id),
- dbesc($contact_id)
- );
- if (!dbm::is_result($r)) {
- continue;
- }
-
- if ($a->maxload_reached()) {
- return;
- }
-
- // It's ours to deliver. Remove it from the queue.
-
- q("DELETE FROM `deliverq` WHERE `cmd` = '%s' AND `item` = %d AND `contact` = %d",
- dbesc($cmd),
- dbesc($item_id),
- dbesc($contact_id)
- );
-
if (!$item_id || !$contact_id) {
continue;
}
$uid = $item_id;
} else {
// find ancestors
- $r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1",
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND visible = 1 AND moderated = 0 LIMIT 1",
intval($item_id)
);
- if ((!dbm::is_result($r)) || (!intval($r[0]['parent']))) {
+ if ((!DBM::is_result($r)) || (!intval($r[0]['parent']))) {
continue;
}
$updated = $r[0]['edited'];
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
- FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d and visible = 1 and moderated = 0 ORDER BY `id` ASC",
+ FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible = 1 AND moderated = 0 ORDER BY `id` ASC",
intval($parent_id)
);
intval($uid)
);
- if (!dbm::is_result($r)) {
+ if (!DBM::is_result($r)) {
continue;
}
$public_message = true;
if (!($mail || $fsuggest || $relocate)) {
- require_once('include/group.php');
+ require_once 'include/group.php';
$parent = $items[0];
intval($contact_id)
);
- if (dbm::is_result($r)) {
+ if (DBM::is_result($r)) {
$contact = $r[0];
}
if ($contact['self']) {
if ($mail) {
$item['body'] = fix_private_photos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
- $atom = dfrn::mail($item, $owner);
+ $atom = DFRN::mail($item, $owner);
} elseif ($fsuggest) {
- $atom = dfrn::fsuggest($item, $owner);
+ $atom = DFRN::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate) {
- $atom = dfrn::relocate($owner, $uid);
+ $atom = DFRN::relocate($owner, $uid);
} elseif ($followup) {
$msgitems = array();
foreach ($items as $item) { // there is only one item
$msgitems[] = $item;
}
}
- $atom = dfrn::entries($msgitems,$owner);
+ $atom = DFRN::entries($msgitems,$owner);
} else {
$msgitems = array();
foreach ($items as $item) {
$msgitems[] = $item;
}
}
- $atom = dfrn::entries($msgitems,$owner);
+ $atom = DFRN::entries($msgitems,$owner);
}
logger('notifier entry: '.$contact["url"].' '.$target_item["guid"].' entry: '.$atom, LOGGER_DEBUG);
// perform local delivery if we are on the same site
- if (link_compare($basepath,App::get_baseurl())) {
+ if (link_compare($basepath,System::baseUrl())) {
$nickname = basename($contact['url']);
if ($contact['issued-id']) {
$x[0]['writable'] = 1;
}
- $ssl_policy = get_config('system','ssl_policy');
+ $ssl_policy = Config::get('system','ssl_policy');
fix_contact_ssl_policy($x[0],$ssl_policy);
// If we are setup as a soapbox we aren't accepting top level posts from this person
- if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) {
+ if (($x[0]['page-flags'] == PAGE_SOAPBOX) && $top_level) {
break;
}
logger('mod-delivery: local delivery');
- dfrn::import($atom, $x[0]);
+ DFRN::import($atom, $x[0]);
break;
}
}
if (!was_recently_delayed($contact['id'])) {
- $deliver_status = dfrn::deliver($owner,$contact,$atom);
+ $deliver_status = DFRN::deliver($owner,$contact,$atom);
} else {
$deliver_status = (-1);
}
if ($owner['prvnets']) {
break;
}
- if (get_config('system','ostatus_disabled') || get_config('system','dfrn_only')) {
+ if (Config::get('system','ostatus_disabled') || Config::get('system','dfrn_only')) {
break;
}
case NETWORK_MAIL:
case NETWORK_MAIL2:
- if (get_config('system','dfrn_only')) {
+ if (Config::get('system','dfrn_only')) {
break;
}
// WARNING: does not currently convert to RFC2047 header encodings, etc.
intval($argv[2]),
intval($uid)
);
- if (dbm::is_result($r))
+ if (DBM::is_result($r))
$it = $r[0];
}
if (!$it)
$headers .= "References: <".iri2msgid($it["parent-uri"]).">";
// If Threading is enabled, write down the correct parent
- if (($it["thr-parent"] != "") and ($it["thr-parent"] != $it["parent-uri"]))
+ if (($it["thr-parent"] != "") && ($it["thr-parent"] != $it["parent-uri"]))
$headers .= " <".iri2msgid($it["thr-parent"]).">";
$headers .= "\n";
dbesc($it['parent-uri']),
intval($uid));
- if (dbm::is_result($r) AND ($r[0]['title'] != '')) {
+ if (DBM::is_result($r) && ($r[0]['title'] != '')) {
$subject = $r[0]['title'];
} else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
- if (dbm::is_result($r) AND ($r[0]['title'] != ''))
+ if (DBM::is_result($r) && ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}
logger('delivery: diaspora batch deliver: '.$loc);
- if (get_config('system','dfrn_only') || (!get_config('system','diaspora_enabled')))
+ if (Config::get('system','dfrn_only') || (!Config::get('system','diaspora_enabled')))
break;
if ($mail) {
logger('diaspora retract: '.$loc);
Diaspora::send_retraction($target_item,$owner,$contact,$public_message);
break;
+ } elseif ($relocate) {
+ Diaspora::sendAccountMigration($owner, $contact, $uid);
+ break;
} elseif ($followup) {
// send comments and likes to owner to relay
logger('diaspora followup: '.$loc);
return;
}
-
-if (array_search(__file__,get_included_files())===0){
- delivery_run($_SERVER["argv"],$_SERVER["argc"]);
- killme();
-}