mirror of
https://github.com/friendica/friendica
synced 2025-05-05 23:04:09 +02:00
Log function
implement log() function.
This commit is contained in:
parent
d6d593d724
commit
14fde5dc9b
122 changed files with 1280 additions and 1161 deletions
|
@ -5,9 +5,10 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
|
||||
class APDelivery extends BaseObject
|
||||
|
@ -22,7 +23,7 @@ class APDelivery extends BaseObject
|
|||
*/
|
||||
public static function execute($cmd, $item_id, $inbox, $uid)
|
||||
{
|
||||
logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
|
||||
Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
|
||||
|
||||
$success = true;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
|
@ -21,7 +22,7 @@ class CheckVersion
|
|||
{
|
||||
public static function execute()
|
||||
{
|
||||
logger('checkversion: start');
|
||||
Logger::log('checkversion: start');
|
||||
|
||||
$checkurl = Config::get('system', 'check_new_version_url', 'none');
|
||||
|
||||
|
@ -36,15 +37,15 @@ class CheckVersion
|
|||
// don't check
|
||||
return;
|
||||
}
|
||||
logger("Checking VERSION from: ".$checked_url, LOGGER_DEBUG);
|
||||
Logger::log("Checking VERSION from: ".$checked_url, LOGGER_DEBUG);
|
||||
|
||||
// fetch the VERSION file
|
||||
$gitversion = DBA::escape(trim(Network::fetchUrl($checked_url)));
|
||||
logger("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG);
|
||||
Logger::log("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG);
|
||||
|
||||
Config::set('system', 'git_friendica_version', $gitversion);
|
||||
|
||||
logger('checkversion: end');
|
||||
Logger::log('checkversion: end');
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\BaseObject;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -38,12 +39,12 @@ class Cron
|
|||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
logger('cron intervall not reached');
|
||||
Logger::log('cron intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logger('cron: start');
|
||||
Logger::log('cron: start');
|
||||
|
||||
// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
|
||||
Hook::fork($a->queue['priority'], "cron");
|
||||
|
@ -124,7 +125,7 @@ class Cron
|
|||
// Poll contacts
|
||||
self::pollContacts($parameter, $generation);
|
||||
|
||||
logger('cron: end');
|
||||
Logger::log('cron: end');
|
||||
|
||||
Config::set('system', 'last_cron', time());
|
||||
|
||||
|
@ -287,7 +288,7 @@ class Cron
|
|||
$priority = PRIORITY_LOW;
|
||||
}
|
||||
|
||||
logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||
Logger::log("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], 'OnePoll', (int)$contact['id']);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\App;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\PostUpdate;
|
||||
|
@ -33,7 +34,7 @@ class CronJobs
|
|||
return;
|
||||
}
|
||||
|
||||
logger("Starting cronjob " . $command, LOGGER_DEBUG);
|
||||
Logger::log("Starting cronjob " . $command, LOGGER_DEBUG);
|
||||
|
||||
// Call possible post update functions
|
||||
// see src/Database/PostUpdate.php for more details
|
||||
|
@ -82,7 +83,7 @@ class CronJobs
|
|||
return;
|
||||
}
|
||||
|
||||
logger("Xronjob " . $command . " is unknown.", LOGGER_DEBUG);
|
||||
Logger::log("Xronjob " . $command . " is unknown.", LOGGER_DEBUG);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -211,7 +212,7 @@ class CronJobs
|
|||
// Calculate fragmentation
|
||||
$fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
|
||||
|
||||
logger("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), LOGGER_DEBUG);
|
||||
Logger::log("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), LOGGER_DEBUG);
|
||||
|
||||
// Don't optimize tables that needn't to be optimized
|
||||
if ($fragmentation < $fragmentation_level) {
|
||||
|
@ -219,7 +220,7 @@ class CronJobs
|
|||
}
|
||||
|
||||
// So optimize it
|
||||
logger("Optimize Table " . $table["Name"], LOGGER_DEBUG);
|
||||
Logger::log("Optimize Table " . $table["Name"], LOGGER_DEBUG);
|
||||
q("OPTIMIZE TABLE `%s`", DBA::escape($table["Name"]));
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +259,7 @@ class CronJobs
|
|||
continue;
|
||||
}
|
||||
|
||||
logger("Repair contact " . $contact["id"] . " " . $contact["url"], LOGGER_DEBUG);
|
||||
Logger::log("Repair contact " . $contact["id"] . " " . $contact["url"], LOGGER_DEBUG);
|
||||
q("UPDATE `contact` SET `batch` = '%s', `notify` = '%s', `poll` = '%s', pubkey = '%s' WHERE `id` = %d",
|
||||
DBA::escape($data["batch"]), DBA::escape($data["notify"]), DBA::escape($data["poll"]), DBA::escape($data["pubkey"]),
|
||||
intval($contact["id"]));
|
||||
|
@ -276,7 +277,7 @@ class CronJobs
|
|||
$r = q("SELECT `uid` FROM `user` WHERE NOT EXISTS (SELECT `uid` FROM `contact` WHERE `contact`.`uid` = `user`.`uid` AND `contact`.`self`)");
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r AS $user) {
|
||||
logger('Create missing self contact for user ' . $user['uid']);
|
||||
Logger::log('Create missing self contact for user ' . $user['uid']);
|
||||
Contact::createSelfFromUserId($user['uid']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
|
@ -80,46 +81,46 @@ class DBClean {
|
|||
|
||||
$last_id = Config::get('system', 'dbclean-last-id-1', 0);
|
||||
|
||||
logger("Deleting old global item entries from item table without user copy. Last ID: ".$last_id);
|
||||
Logger::log("Deleting old global item entries from item table without user copy. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
|
||||
NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
|
||||
`received` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `id` >= ?
|
||||
ORDER BY `id` LIMIT ?", $days_unclaimed, $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found global item orphans: ".$count);
|
||||
Logger::log("found global item orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id);
|
||||
} else {
|
||||
logger("No global item orphans found");
|
||||
Logger::log("No global item orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." old global item entries from item table without user copy. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." old global item entries from item table without user copy. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-1', $last_id);
|
||||
} elseif ($stage == 2) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-2', 0);
|
||||
|
||||
logger("Deleting items without parents. Last ID: ".$last_id);
|
||||
Logger::log("Deleting items without parents. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `id` FROM `item`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`)
|
||||
AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found item orphans without parents: ".$count);
|
||||
Logger::log("found item orphans without parents: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id);
|
||||
} else {
|
||||
logger("No item orphans without parents found");
|
||||
Logger::log("No item orphans without parents found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." items without parents. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." items without parents. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-2', $last_id);
|
||||
|
||||
|
@ -129,23 +130,23 @@ class DBClean {
|
|||
} elseif ($stage == 3) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-3', 0);
|
||||
|
||||
logger("Deleting orphaned data from thread table. Last ID: ".$last_id);
|
||||
Logger::log("Deleting orphaned data from thread table. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `iid` FROM `thread`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) AND `iid` >= ?
|
||||
ORDER BY `iid` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found thread orphans: ".$count);
|
||||
Logger::log("found thread orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["iid"];
|
||||
DBA::delete('thread', ['iid' => $orphan["iid"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 3, $last_id);
|
||||
} else {
|
||||
logger("No thread orphans found");
|
||||
Logger::log("No thread orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." orphaned data from thread table. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." orphaned data from thread table. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-3', $last_id);
|
||||
|
||||
|
@ -155,23 +156,23 @@ class DBClean {
|
|||
} elseif ($stage == 4) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-4', 0);
|
||||
|
||||
logger("Deleting orphaned data from notify table. Last ID: ".$last_id);
|
||||
Logger::log("Deleting orphaned data from notify table. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `iid`, `id` FROM `notify`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) AND `id` >= ?
|
||||
ORDER BY `id` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found notify orphans: ".$count);
|
||||
Logger::log("found notify orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('notify', ['iid' => $orphan["iid"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 4, $last_id);
|
||||
} else {
|
||||
logger("No notify orphans found");
|
||||
Logger::log("No notify orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." orphaned data from notify table. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." orphaned data from notify table. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-4', $last_id);
|
||||
|
||||
|
@ -181,23 +182,23 @@ class DBClean {
|
|||
} elseif ($stage == 5) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-5', 0);
|
||||
|
||||
logger("Deleting orphaned data from notify-threads table. Last ID: ".$last_id);
|
||||
Logger::log("Deleting orphaned data from notify-threads table. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `id` FROM `notify-threads`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) AND `id` >= ?
|
||||
ORDER BY `id` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found notify-threads orphans: ".$count);
|
||||
Logger::log("found notify-threads orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('notify-threads', ['id' => $orphan["id"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 5, $last_id);
|
||||
} else {
|
||||
logger("No notify-threads orphans found");
|
||||
Logger::log("No notify-threads orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." orphaned data from notify-threads table. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." orphaned data from notify-threads table. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-5', $last_id);
|
||||
|
||||
|
@ -207,23 +208,23 @@ class DBClean {
|
|||
} elseif ($stage == 6) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-6', 0);
|
||||
|
||||
logger("Deleting orphaned data from sign table. Last ID: ".$last_id);
|
||||
Logger::log("Deleting orphaned data from sign table. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `iid`, `id` FROM `sign`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) AND `id` >= ?
|
||||
ORDER BY `id` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found sign orphans: ".$count);
|
||||
Logger::log("found sign orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('sign', ['iid' => $orphan["iid"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 6, $last_id);
|
||||
} else {
|
||||
logger("No sign orphans found");
|
||||
Logger::log("No sign orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." orphaned data from sign table. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." orphaned data from sign table. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-6', $last_id);
|
||||
|
||||
|
@ -233,23 +234,23 @@ class DBClean {
|
|||
} elseif ($stage == 7) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-7', 0);
|
||||
|
||||
logger("Deleting orphaned data from term table. Last ID: ".$last_id);
|
||||
Logger::log("Deleting orphaned data from term table. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `oid`, `tid` FROM `term`
|
||||
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) AND `tid` >= ?
|
||||
ORDER BY `tid` LIMIT ?", $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found term orphans: ".$count);
|
||||
Logger::log("found term orphans: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["tid"];
|
||||
DBA::delete('term', ['oid' => $orphan["oid"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 7, $last_id);
|
||||
} else {
|
||||
logger("No term orphans found");
|
||||
Logger::log("No term orphans found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." orphaned data from term table. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." orphaned data from term table. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-7', $last_id);
|
||||
|
||||
|
@ -263,7 +264,7 @@ class DBClean {
|
|||
|
||||
$last_id = Config::get('system', 'dbclean-last-id-8', 0);
|
||||
|
||||
logger("Deleting expired threads. Last ID: ".$last_id);
|
||||
Logger::log("Deleting expired threads. Last ID: ".$last_id);
|
||||
$r = DBA::p("SELECT `thread`.`iid` FROM `thread`
|
||||
INNER JOIN `contact` ON `thread`.`contact-id` = `contact`.`id` AND NOT `notify_new_posts`
|
||||
WHERE `thread`.`received` < UTC_TIMESTAMP() - INTERVAL ? DAY
|
||||
|
@ -278,17 +279,17 @@ class DBClean {
|
|||
ORDER BY `thread`.`iid` LIMIT ?", $days, $last_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found expired threads: ".$count);
|
||||
Logger::log("found expired threads: ".$count);
|
||||
while ($thread = DBA::fetch($r)) {
|
||||
$last_id = $thread["iid"];
|
||||
DBA::delete('thread', ['iid' => $thread["iid"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 8, $last_id);
|
||||
} else {
|
||||
logger("No expired threads found");
|
||||
Logger::log("No expired threads found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." expired threads. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." expired threads. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-8', $last_id);
|
||||
} elseif ($stage == 9) {
|
||||
|
@ -299,47 +300,47 @@ class DBClean {
|
|||
$last_id = Config::get('system', 'dbclean-last-id-9', 0);
|
||||
$till_id = Config::get('system', 'dbclean-last-id-8', 0);
|
||||
|
||||
logger("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id);
|
||||
Logger::log("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id);
|
||||
$r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
|
||||
NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
|
||||
`received` < UTC_TIMESTAMP() - INTERVAL 90 DAY AND `id` >= ? AND `id` <= ?
|
||||
ORDER BY `id` LIMIT ?", $last_id, $till_id, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found global item entries from expired threads: ".$count);
|
||||
Logger::log("found global item entries from expired threads: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["id"];
|
||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id);
|
||||
} else {
|
||||
logger("No global item entries from expired threads");
|
||||
Logger::log("No global item entries from expired threads");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." old global item entries from expired threads. Last ID: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." old global item entries from expired threads. Last ID: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-9', $last_id);
|
||||
} elseif ($stage == 10) {
|
||||
$last_id = Config::get('system', 'dbclean-last-id-10', 0);
|
||||
$days = intval(Config::get('system', 'dbclean_expire_conversation', 90));
|
||||
|
||||
logger("Deleting old conversations. Last created: ".$last_id);
|
||||
Logger::log("Deleting old conversations. Last created: ".$last_id);
|
||||
$r = DBA::p("SELECT `received`, `item-uri` FROM `conversation`
|
||||
WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
|
||||
ORDER BY `received` LIMIT ?", $days, $limit);
|
||||
$count = DBA::numRows($r);
|
||||
if ($count > 0) {
|
||||
logger("found old conversations: ".$count);
|
||||
Logger::log("found old conversations: ".$count);
|
||||
while ($orphan = DBA::fetch($r)) {
|
||||
$last_id = $orphan["received"];
|
||||
DBA::delete('conversation', ['item-uri' => $orphan["item-uri"]]);
|
||||
}
|
||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 10, $last_id);
|
||||
} else {
|
||||
logger("No old conversations found");
|
||||
Logger::log("No old conversations found");
|
||||
}
|
||||
DBA::close($r);
|
||||
logger("Done deleting ".$count." conversations. Last created: ".$last_id);
|
||||
Logger::log("Done deleting ".$count." conversations. Last created: ".$last_id);
|
||||
|
||||
Config::set('system', 'dbclean-last-id-10', $last_id);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -33,7 +34,7 @@ class Delivery extends BaseObject
|
|||
|
||||
public static function execute($cmd, $item_id, $contact_id)
|
||||
{
|
||||
logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, LOGGER_DEBUG);
|
||||
Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, LOGGER_DEBUG);
|
||||
|
||||
$top_level = false;
|
||||
$followup = false;
|
||||
|
@ -78,12 +79,12 @@ class Delivery extends BaseObject
|
|||
DBA::close($itemdata);
|
||||
|
||||
if (empty($target_item)) {
|
||||
logger('Item ' . $item_id . "wasn't found. Quitting here.");
|
||||
Logger::log('Item ' . $item_id . "wasn't found. Quitting here.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($parent)) {
|
||||
logger('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here.");
|
||||
Logger::log('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,7 @@ class Delivery extends BaseObject
|
|||
// The count then showed more than one entry. The additional check should help.
|
||||
// The check for the "count" should be superfluous, but I'm not totally sure by now, so we keep it.
|
||||
if ((($parent['id'] == $item_id) || (count($items) == 1)) && ($parent['uri'] === $parent['parent-uri'])) {
|
||||
logger('Top level post');
|
||||
Logger::log('Top level post');
|
||||
$top_level = true;
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ class Delivery extends BaseObject
|
|||
*/
|
||||
|
||||
if (!$top_level && ($parent['wall'] == 0) && stristr($target_item['uri'], $localhost)) {
|
||||
logger('Followup ' . $target_item["guid"], LOGGER_DEBUG);
|
||||
Logger::log('Followup ' . $target_item["guid"], LOGGER_DEBUG);
|
||||
// local followup to remote post
|
||||
$followup = true;
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ class Delivery extends BaseObject
|
|||
}
|
||||
|
||||
if (empty($items)) {
|
||||
logger('No delivery data for ' . $cmd . ' - Item ID: ' .$item_id . ' - Contact ID: ' . $contact_id);
|
||||
Logger::log('No delivery data for ' . $cmd . ' - Item ID: ' .$item_id . ' - Contact ID: ' . $contact_id);
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
@ -162,7 +163,7 @@ class Delivery extends BaseObject
|
|||
$contact['network'] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
logger("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']);
|
||||
Logger::log("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']);
|
||||
|
||||
switch ($contact['network']) {
|
||||
|
||||
|
@ -212,7 +213,7 @@ class Delivery extends BaseObject
|
|||
*/
|
||||
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
||||
{
|
||||
logger('Deliver ' . $target_item["guid"] . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr']));
|
||||
Logger::log('Deliver ' . $target_item["guid"] . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr']));
|
||||
|
||||
if ($cmd == self::MAIL) {
|
||||
$item = $target_item;
|
||||
|
@ -240,7 +241,7 @@ class Delivery extends BaseObject
|
|||
$atom = DFRN::entries($msgitems, $owner);
|
||||
}
|
||||
|
||||
logger('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, LOGGER_DATA);
|
||||
Logger::log('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, LOGGER_DATA);
|
||||
|
||||
$basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
|
||||
|
||||
|
@ -284,7 +285,7 @@ class Delivery extends BaseObject
|
|||
|
||||
// We never spool failed relay deliveries
|
||||
if ($public_dfrn) {
|
||||
logger('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
|
||||
Logger::log('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -299,10 +300,10 @@ class Delivery extends BaseObject
|
|||
$deliver_status = DFRN::deliver($owner, $contact, $atom, false, true);
|
||||
}
|
||||
|
||||
logger('Delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
|
||||
Logger::log('Delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
|
||||
|
||||
if ($deliver_status < 0) {
|
||||
logger('Delivery failed: queuing message ' . $target_item["guid"] );
|
||||
Logger::log('Delivery failed: queuing message ' . $target_item["guid"] );
|
||||
Queue::add($contact['id'], Protocol::DFRN, $atom, false, $target_item['guid']);
|
||||
}
|
||||
|
||||
|
@ -342,7 +343,7 @@ class Delivery extends BaseObject
|
|||
$loc = $contact['addr'];
|
||||
}
|
||||
|
||||
logger('Deliver ' . $target_item["guid"] . ' via Diaspora to ' . $loc);
|
||||
Logger::log('Deliver ' . $target_item["guid"] . ' via Diaspora to ' . $loc);
|
||||
|
||||
if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) {
|
||||
return;
|
||||
|
@ -360,7 +361,7 @@ class Delivery extends BaseObject
|
|||
}
|
||||
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
|
||||
// top-level retraction
|
||||
logger('diaspora retract: ' . $loc);
|
||||
Logger::log('diaspora retract: ' . $loc);
|
||||
Diaspora::sendRetraction($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($cmd == self::RELOCATION) {
|
||||
|
@ -368,22 +369,22 @@ class Delivery extends BaseObject
|
|||
return;
|
||||
} elseif ($followup) {
|
||||
// send comments and likes to owner to relay
|
||||
logger('diaspora followup: ' . $loc);
|
||||
Logger::log('diaspora followup: ' . $loc);
|
||||
Diaspora::sendFollowup($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
||||
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
||||
logger('diaspora relay: ' . $loc);
|
||||
Logger::log('diaspora relay: ' . $loc);
|
||||
Diaspora::sendRelay($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
} elseif ($top_level && !$walltowall) {
|
||||
// currently no workable solution for sending walltowall
|
||||
logger('diaspora status: ' . $loc);
|
||||
Logger::log('diaspora status: ' . $loc);
|
||||
Diaspora::sendStatus($target_item, $owner, $contact, $public_message);
|
||||
return;
|
||||
}
|
||||
|
||||
logger('Unknown mode ' . $cmd . ' for ' . $loc);
|
||||
Logger::log('Unknown mode ' . $cmd . ' for ' . $loc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,7 +416,7 @@ class Delivery extends BaseObject
|
|||
return;
|
||||
}
|
||||
|
||||
logger('Deliver ' . $target_item["guid"] . ' via mail to ' . $contact['addr']);
|
||||
Logger::log('Deliver ' . $target_item["guid"] . ' via mail to ' . $contact['addr']);
|
||||
|
||||
$reply_to = '';
|
||||
$mailacct = DBA::selectFirst('mailacct', ['reply_to'], ['uid' => $owner['uid']]);
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Friendica\Worker;
|
|||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -33,7 +34,7 @@ class Directory
|
|||
|
||||
Addon::callHooks('globaldir_update', $arr);
|
||||
|
||||
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
||||
Logger::log('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
||||
if (strlen($arr['url'])) {
|
||||
Network::fetchUrl($dir . '?url=' . bin2hex($arr['url']));
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Friendica\Worker;
|
|||
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -52,11 +53,11 @@ class DiscoverPoCo
|
|||
} elseif ($command == "check_profile") {
|
||||
$mode = 8;
|
||||
} elseif ($command !== "") {
|
||||
logger("Unknown or missing parameter ".$command."\n");
|
||||
Logger::log("Unknown or missing parameter ".$command."\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logger('start '.$search);
|
||||
Logger::log('start '.$search);
|
||||
|
||||
if ($mode == 8) {
|
||||
if ($param1 != "") {
|
||||
|
@ -89,7 +90,7 @@ class DiscoverPoCo
|
|||
} else {
|
||||
$result .= "failed";
|
||||
}
|
||||
logger($result, LOGGER_DEBUG);
|
||||
Logger::log($result, LOGGER_DEBUG);
|
||||
} elseif ($mode == 3) {
|
||||
GContact::updateSuggestions();
|
||||
} elseif (($mode == 2) && Config::get('system', 'poco_completion')) {
|
||||
|
@ -107,7 +108,7 @@ class DiscoverPoCo
|
|||
}
|
||||
}
|
||||
|
||||
logger('end '.$search);
|
||||
Logger::log('end '.$search);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -129,7 +130,7 @@ class DiscoverPoCo
|
|||
if (!PortableContact::updateNeeded($server["created"], "", $server["last_failure"], $server["last_contact"])) {
|
||||
continue;
|
||||
}
|
||||
logger('Update server status for server '.$server["url"], LOGGER_DEBUG);
|
||||
Logger::log('Update server status for server '.$server["url"], LOGGER_DEBUG);
|
||||
|
||||
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server["url"]);
|
||||
|
||||
|
@ -140,7 +141,7 @@ class DiscoverPoCo
|
|||
}
|
||||
|
||||
private static function discoverUsers() {
|
||||
logger("Discover users", LOGGER_DEBUG);
|
||||
Logger::log("Discover users", LOGGER_DEBUG);
|
||||
|
||||
$starttime = time();
|
||||
|
||||
|
@ -184,7 +185,7 @@ class DiscoverPoCo
|
|||
}
|
||||
|
||||
if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
|
||||
logger('Check profile '.$user["url"]);
|
||||
Logger::log('Check profile '.$user["url"]);
|
||||
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]);
|
||||
|
||||
if (++$checked > 100) {
|
||||
|
@ -208,7 +209,7 @@ class DiscoverPoCo
|
|||
if (!is_null($data)) {
|
||||
// Only search for the same item every 24 hours
|
||||
if (time() < $data + (60 * 60 * 24)) {
|
||||
logger("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG);
|
||||
Logger::log("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +222,7 @@ class DiscoverPoCo
|
|||
// Check if the contact already exists
|
||||
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
||||
if (DBA::isResult($exists)) {
|
||||
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||
Logger::log("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) &&
|
||||
($exists[0]["updated"] < $exists[0]["last_failure"])) {
|
||||
|
@ -235,16 +236,16 @@ class DiscoverPoCo
|
|||
$server_url = PortableContact::detectServer($jj->url);
|
||||
if ($server_url != '') {
|
||||
if (!PortableContact::checkServer($server_url)) {
|
||||
logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
||||
Logger::log("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
||||
continue;
|
||||
}
|
||||
logger("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG);
|
||||
Logger::log("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$data = Probe::uri($jj->url);
|
||||
if ($data["network"] == Protocol::DFRN) {
|
||||
logger("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
|
||||
logger("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG);
|
||||
Logger::log("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
|
||||
Logger::log("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
if ($jj->tags != "") {
|
||||
$data["keywords"] = $jj->tags;
|
||||
|
@ -254,7 +255,7 @@ class DiscoverPoCo
|
|||
|
||||
GContact::update($data);
|
||||
} else {
|
||||
logger("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG);
|
||||
Logger::log("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -26,7 +27,7 @@ class Expire
|
|||
Hook::loadHooks();
|
||||
|
||||
if ($param == 'delete') {
|
||||
logger('Delete expired items', LOGGER_DEBUG);
|
||||
Logger::log('Delete expired items', LOGGER_DEBUG);
|
||||
// physically remove anything that has been deleted for more than two months
|
||||
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
||||
$rows = DBA::select('item', ['id'], $condition);
|
||||
|
@ -37,62 +38,62 @@ class Expire
|
|||
|
||||
// Normally we shouldn't have orphaned data at all.
|
||||
// If we do have some, then we have to check why.
|
||||
logger('Deleting orphaned item activities - start', LOGGER_DEBUG);
|
||||
Logger::log('Deleting orphaned item activities - start', LOGGER_DEBUG);
|
||||
$condition = ["NOT EXISTS (SELECT `iaid` FROM `item` WHERE `item`.`iaid` = `item-activity`.`id`)"];
|
||||
DBA::delete('item-activity', $condition);
|
||||
logger('Orphaned item activities deleted: ' . DBA::affectedRows(), LOGGER_DEBUG);
|
||||
Logger::log('Orphaned item activities deleted: ' . DBA::affectedRows(), LOGGER_DEBUG);
|
||||
|
||||
logger('Deleting orphaned item content - start', LOGGER_DEBUG);
|
||||
Logger::log('Deleting orphaned item content - start', LOGGER_DEBUG);
|
||||
$condition = ["NOT EXISTS (SELECT `icid` FROM `item` WHERE `item`.`icid` = `item-content`.`id`)"];
|
||||
DBA::delete('item-content', $condition);
|
||||
logger('Orphaned item content deleted: ' . DBA::affectedRows(), LOGGER_DEBUG);
|
||||
Logger::log('Orphaned item content deleted: ' . DBA::affectedRows(), LOGGER_DEBUG);
|
||||
|
||||
// make this optional as it could have a performance impact on large sites
|
||||
if (intval(Config::get('system', 'optimize_items'))) {
|
||||
DBA::e("OPTIMIZE TABLE `item`");
|
||||
}
|
||||
|
||||
logger('Delete expired items - done', LOGGER_DEBUG);
|
||||
Logger::log('Delete expired items - done', LOGGER_DEBUG);
|
||||
return;
|
||||
} elseif (intval($param) > 0) {
|
||||
$user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
|
||||
if (DBA::isResult($user)) {
|
||||
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
|
||||
Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
|
||||
Item::expire($user['uid'], $user['expire']);
|
||||
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG);
|
||||
Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG);
|
||||
}
|
||||
return;
|
||||
} elseif ($param == 'hook' && !empty($hook_function)) {
|
||||
foreach (Hook::getByName('expire') as $hook) {
|
||||
if ($hook[1] == $hook_function) {
|
||||
logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Logger::log("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Hook::callSingle($a, 'expire', $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
logger('expire: start');
|
||||
Logger::log('expire: start');
|
||||
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Expire', 'delete');
|
||||
|
||||
$r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0");
|
||||
while ($row = DBA::fetch($r)) {
|
||||
logger('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG);
|
||||
Logger::log('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Expire', (int)$row['uid']);
|
||||
}
|
||||
DBA::close($r);
|
||||
|
||||
logger('expire: calling hooks');
|
||||
Logger::log('expire: calling hooks');
|
||||
foreach (Hook::getByName('expire') as $hook) {
|
||||
logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Logger::log("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Expire', 'hook', $hook[1]);
|
||||
}
|
||||
|
||||
logger('expire: end');
|
||||
Logger::log('expire: end');
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\GContact;
|
||||
|
@ -24,7 +25,7 @@ class GProbe {
|
|||
DBA::escape(normalise_link($url))
|
||||
);
|
||||
|
||||
logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
|
||||
Logger::log("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
// Is it a DDoS attempt?
|
||||
|
@ -33,7 +34,7 @@ class GProbe {
|
|||
$result = Cache::get("gprobe:".$urlparts["host"]);
|
||||
if (!is_null($result)) {
|
||||
if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
|
||||
logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
|
||||
Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +61,7 @@ class GProbe {
|
|||
}
|
||||
}
|
||||
|
||||
logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
|
||||
Logger::log("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\BaseObject;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -57,7 +58,7 @@ class Notifier
|
|||
{
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
logger('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG);
|
||||
Logger::log('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG);
|
||||
|
||||
$top_level = false;
|
||||
$recipients = [];
|
||||
|
@ -104,7 +105,7 @@ class Notifier
|
|||
|
||||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0);
|
||||
foreach ($inboxes as $inbox) {
|
||||
logger('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
Logger::log('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'APDelivery', Delivery::REMOVAL, '', $inbox, $item_id);
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ class Notifier
|
|||
}
|
||||
|
||||
if ((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
|
||||
logger('notifier: top level post');
|
||||
Logger::log('notifier: top level post');
|
||||
$top_level = true;
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +185,7 @@ class Notifier
|
|||
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
|
||||
$thr_parent = Item::selectFirst($fields, $condition);
|
||||
|
||||
logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG);
|
||||
Logger::log('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG);
|
||||
|
||||
// This is IMPORTANT!!!!
|
||||
|
||||
|
@ -248,7 +249,7 @@ class Notifier
|
|||
$recipients = [$parent['contact-id']];
|
||||
$recipients_followup = [$parent['contact-id']];
|
||||
|
||||
logger('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG);
|
||||
Logger::log('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG);
|
||||
|
||||
//if (!$target_item['private'] && $target_item['wall'] &&
|
||||
if (!$target_item['private'] &&
|
||||
|
@ -278,16 +279,16 @@ class Notifier
|
|||
$push_notify = false;
|
||||
}
|
||||
|
||||
logger("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG);
|
||||
Logger::log("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG);
|
||||
} else {
|
||||
$followup = false;
|
||||
|
||||
logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
|
||||
Logger::log('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
|
||||
|
||||
// don't send deletions onward for other people's stuff
|
||||
|
||||
if ($target_item['deleted'] && !intval($target_item['wall'])) {
|
||||
logger('notifier: ignoring delete notification for non-wall item');
|
||||
Logger::log('notifier: ignoring delete notification for non-wall item');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -328,7 +329,7 @@ class Notifier
|
|||
}
|
||||
|
||||
if (count($url_recipients)) {
|
||||
logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
|
||||
Logger::log('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
|
||||
}
|
||||
|
||||
$conversants = array_unique($conversants);
|
||||
|
@ -345,31 +346,31 @@ class Notifier
|
|||
if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) {
|
||||
$diaspora_delivery = false;
|
||||
|
||||
logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG);
|
||||
Logger::log('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG);
|
||||
|
||||
// Send a salmon to the parent author
|
||||
$probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]);
|
||||
if (DBA::isResult($probed_contact) && !empty($probed_contact["notify"])) {
|
||||
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
Logger::log('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
||||
}
|
||||
|
||||
// Send a salmon to the parent owner
|
||||
$probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['owner-id']]);
|
||||
if (DBA::isResult($probed_contact) && !empty($probed_contact["notify"])) {
|
||||
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
Logger::log('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
||||
}
|
||||
|
||||
// Send a salmon notification to every person we mentioned in the post
|
||||
$arr = explode(',',$target_item['tag']);
|
||||
foreach ($arr as $x) {
|
||||
//logger('Checking tag '.$x, LOGGER_DEBUG);
|
||||
//Logger::log('Checking tag '.$x, LOGGER_DEBUG);
|
||||
$matches = null;
|
||||
if (preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
|
||||
$probed_contact = Probe::uri($matches[1]);
|
||||
if ($probed_contact["notify"] != "") {
|
||||
logger('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
Logger::log('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
|
||||
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +420,7 @@ class Notifier
|
|||
// delivery loop
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $contact) {
|
||||
logger("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
|
||||
Logger::log("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
|
||||
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Delivery', $cmd, $item_id, (int)$contact['id']);
|
||||
|
@ -432,7 +433,7 @@ class Notifier
|
|||
$slap = OStatus::salmon($target_item, $owner);
|
||||
foreach ($url_recipients as $url) {
|
||||
if ($url) {
|
||||
logger('notifier: urldelivery: ' . $url);
|
||||
Logger::log('notifier: urldelivery: ' . $url);
|
||||
$deliver_status = Salmon::slapper($owner, $url, $slap);
|
||||
/// @TODO Redeliver/queue these items on failure, though there is no contact record
|
||||
}
|
||||
|
@ -469,19 +470,19 @@ class Notifier
|
|||
$r = array_merge($r2, $r1);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
|
||||
Logger::log('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
|
||||
|
||||
foreach ($r as $rr) {
|
||||
// except for Diaspora batch jobs
|
||||
// Don't deliver to folks who have already been delivered to
|
||||
|
||||
if (($rr['network'] !== Protocol::DIASPORA) && (in_array($rr['id'], $conversants))) {
|
||||
logger('notifier: already delivered id=' . $rr['id']);
|
||||
Logger::log('notifier: already delivered id=' . $rr['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION]) && !$followup) {
|
||||
logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
|
||||
Logger::log('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Delivery', $cmd, $item_id, (int)$rr['id']);
|
||||
}
|
||||
|
@ -493,13 +494,13 @@ class Notifier
|
|||
|
||||
// Notify PuSH subscribers (Used for OStatus distribution of regular posts)
|
||||
if ($push_notify) {
|
||||
logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
|
||||
Logger::log('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
|
||||
|
||||
// Handling the pubsubhubbub requests
|
||||
PushSubscriber::publishFeed($owner['uid'], $a->queue['priority']);
|
||||
}
|
||||
|
||||
logger('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG);
|
||||
Logger::log('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG);
|
||||
|
||||
if ($normal_mode) {
|
||||
Hook::fork($a->queue['priority'], 'notifier_normal', $target_item);
|
||||
|
@ -517,15 +518,15 @@ class Notifier
|
|||
|
||||
if ($target_item['origin']) {
|
||||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid);
|
||||
logger('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG);
|
||||
Logger::log('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG);
|
||||
} elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) {
|
||||
logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG);
|
||||
Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG);
|
||||
return;
|
||||
} else {
|
||||
// Remote items are transmitted via the personal inboxes.
|
||||
// Doing so ensures that the dedicated receiver will get the message.
|
||||
$personal = true;
|
||||
logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG);
|
||||
Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
if ($parent['origin']) {
|
||||
|
@ -534,7 +535,7 @@ class Notifier
|
|||
}
|
||||
|
||||
if (empty($inboxes)) {
|
||||
logger('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG);
|
||||
Logger::log('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -542,7 +543,7 @@ class Notifier
|
|||
ActivityPub\Transmitter::createCachedActivityFromItem($item_id, true);
|
||||
|
||||
foreach ($inboxes as $inbox) {
|
||||
logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
Logger::log('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'APDelivery', $cmd, $item_id, $inbox, $uid);
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -29,7 +30,7 @@ class OnePoll
|
|||
|
||||
require_once 'include/items.php';
|
||||
|
||||
logger('start');
|
||||
Logger::log('start');
|
||||
|
||||
$manual_id = 0;
|
||||
$generation = 0;
|
||||
|
@ -42,7 +43,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
if (!$contact_id) {
|
||||
logger('no contact');
|
||||
Logger::log('no contact');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,7 @@ class OnePoll
|
|||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
logger('Contact not found or cannot be used.');
|
||||
Logger::log('Contact not found or cannot be used.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ class OnePoll
|
|||
$updated = DateTimeFormat::utcNow();
|
||||
|
||||
if ($last_updated) {
|
||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
Logger::log('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
|
||||
// The last public item can be older than the last item we got
|
||||
if ($last_updated < $contact['last-item']) {
|
||||
|
@ -99,7 +100,7 @@ class OnePoll
|
|||
} else {
|
||||
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
||||
Contact::markForArchival($contact);
|
||||
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||
Logger::log('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -129,7 +130,7 @@ class OnePoll
|
|||
// Update the contact entry
|
||||
if (($contact['network'] === Protocol::OSTATUS) || ($contact['network'] === Protocol::DIASPORA) || ($contact['network'] === Protocol::DFRN)) {
|
||||
if (!PortableContact::reachable($contact['url'])) {
|
||||
logger("Skipping probably dead contact ".$contact['url']);
|
||||
Logger::log("Skipping probably dead contact ".$contact['url']);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
@ -138,7 +139,7 @@ class OnePoll
|
|||
|
||||
if (!Contact::updateFromProbe($contact["id"])) {
|
||||
Contact::markForArchival($contact);
|
||||
logger('Contact is marked dead');
|
||||
Logger::log('Contact is marked dead');
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
@ -153,7 +154,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
if ($importer_uid == 0) {
|
||||
logger('Ignore public contacts');
|
||||
Logger::log('Ignore public contacts');
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
@ -165,7 +166,7 @@ class OnePoll
|
|||
);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
logger('No self contact for user '.$importer_uid);
|
||||
Logger::log('No self contact for user '.$importer_uid);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
@ -175,7 +176,7 @@ class OnePoll
|
|||
$importer = $r[0];
|
||||
$url = '';
|
||||
|
||||
logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
Logger::log("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
|
||||
if ($contact['network'] === Protocol::DFRN) {
|
||||
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
|
||||
|
@ -213,10 +214,10 @@ class OnePoll
|
|||
$handshake_xml = $curlResult->getBody();
|
||||
$html_code = $curlResult->getReturnCode();
|
||||
|
||||
logger('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
|
||||
Logger::log('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
|
||||
|
||||
if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
|
||||
logger("$url appears to be dead - marking for death ");
|
||||
Logger::log("$url appears to be dead - marking for death ");
|
||||
|
||||
// dead connection - might be a transient event, or this might
|
||||
// mean the software was uninstalled or the domain expired.
|
||||
|
@ -231,7 +232,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
if (!strstr($handshake_xml, '<')) {
|
||||
logger('response from ' . $url . ' did not contain XML.');
|
||||
Logger::log('response from ' . $url . ' did not contain XML.');
|
||||
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
|
@ -244,7 +245,7 @@ class OnePoll
|
|||
$res = XML::parseString($handshake_xml);
|
||||
|
||||
if (intval($res->status) == 1) {
|
||||
logger("$url replied status 1 - marking for death ");
|
||||
Logger::log("$url replied status 1 - marking for death ");
|
||||
|
||||
// we may not be friends anymore. Will keep trying for one month.
|
||||
// set the last-update so we don't keep polling
|
||||
|
@ -253,7 +254,7 @@ class OnePoll
|
|||
|
||||
Contact::markForArchival($contact);
|
||||
} elseif ($contact['term-date'] > DBA::NULL_DATETIME) {
|
||||
logger("$url back from the dead - removing mark for death");
|
||||
Logger::log("$url back from the dead - removing mark for death");
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
|
@ -291,7 +292,7 @@ class OnePoll
|
|||
|
||||
if ($final_dfrn_id != $orig_id) {
|
||||
// did not decode properly - cannot trust this site
|
||||
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
||||
Logger::log('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
|
@ -347,7 +348,7 @@ class OnePoll
|
|||
$xml = $curlResult->getBody();
|
||||
|
||||
} elseif ($contact['network'] === Protocol::MAIL) {
|
||||
logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
|
||||
Logger::log("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
|
||||
|
||||
$mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1);
|
||||
if ($mail_disabled) {
|
||||
|
@ -357,7 +358,7 @@ class OnePoll
|
|||
return;
|
||||
}
|
||||
|
||||
logger("Mail: Enabled", LOGGER_DEBUG);
|
||||
Logger::log("Mail: Enabled", LOGGER_DEBUG);
|
||||
|
||||
$mbox = null;
|
||||
$user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]);
|
||||
|
@ -370,13 +371,13 @@ class OnePoll
|
|||
openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $user['prvkey']);
|
||||
$mbox = Email::connect($mailbox, $mailconf['user'], $password);
|
||||
unset($password);
|
||||
logger("Mail: Connect to " . $mailconf['user']);
|
||||
Logger::log("Mail: Connect to " . $mailconf['user']);
|
||||
if ($mbox) {
|
||||
$fields = ['last_check' => DateTimeFormat::utcNow()];
|
||||
DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
|
||||
logger("Mail: Connected to " . $mailconf['user']);
|
||||
Logger::log("Mail: Connected to " . $mailconf['user']);
|
||||
} else {
|
||||
logger("Mail: Connection error ".$mailconf['user']." ".print_r(imap_errors(), true));
|
||||
Logger::log("Mail: Connection error ".$mailconf['user']." ".print_r(imap_errors(), true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,17 +385,17 @@ class OnePoll
|
|||
$msgs = Email::poll($mbox, $contact['addr']);
|
||||
|
||||
if (count($msgs)) {
|
||||
logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG);
|
||||
Logger::log("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG);
|
||||
|
||||
$metas = Email::messageMeta($mbox, implode(',', $msgs));
|
||||
|
||||
if (count($metas) != count($msgs)) {
|
||||
logger("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
|
||||
Logger::log("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
|
||||
} else {
|
||||
$msgs = array_combine($msgs, $metas);
|
||||
|
||||
foreach ($msgs as $msg_uid => $meta) {
|
||||
logger("Mail: Parsing mail ".$msg_uid, LOGGER_DATA);
|
||||
Logger::log("Mail: Parsing mail ".$msg_uid, LOGGER_DATA);
|
||||
|
||||
$datarray = [];
|
||||
$datarray['verb'] = ACTIVITY_POST;
|
||||
|
@ -409,7 +410,7 @@ class OnePoll
|
|||
$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
if (DBA::isResult($item)) {
|
||||
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
|
||||
Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
|
||||
|
||||
// Only delete when mails aren't automatically moved or deleted
|
||||
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
|
||||
|
@ -420,18 +421,18 @@ class OnePoll
|
|||
|
||||
switch ($mailconf['action']) {
|
||||
case 0:
|
||||
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG);
|
||||
Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG);
|
||||
break;
|
||||
case 1:
|
||||
logger("Mail: Deleting ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']);
|
||||
imap_delete($mbox, $msg_uid, FT_UID);
|
||||
break;
|
||||
case 2:
|
||||
logger("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']);
|
||||
imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
|
||||
break;
|
||||
case 3:
|
||||
logger("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']);
|
||||
imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
|
||||
if ($mailconf['movetofolder'] != "") {
|
||||
imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID);
|
||||
|
@ -502,13 +503,13 @@ class OnePoll
|
|||
|
||||
$r = Email::getMessage($mbox, $msg_uid, $reply);
|
||||
if (!$r) {
|
||||
logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']);
|
||||
continue;
|
||||
}
|
||||
$datarray['body'] = escape_tags($r['body']);
|
||||
$datarray['body'] = BBCode::limitBodySize($datarray['body']);
|
||||
|
||||
logger("Mail: Importing ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Importing ".$msg_uid." for ".$mailconf['user']);
|
||||
|
||||
/// @TODO Adding a gravatar for the original author would be cool
|
||||
|
||||
|
@ -554,18 +555,18 @@ class OnePoll
|
|||
|
||||
switch ($mailconf['action']) {
|
||||
case 0:
|
||||
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG);
|
||||
Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG);
|
||||
break;
|
||||
case 1:
|
||||
logger("Mail: Deleting ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']);
|
||||
imap_delete($mbox, $msg_uid, FT_UID);
|
||||
break;
|
||||
case 2:
|
||||
logger("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']);
|
||||
imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
|
||||
break;
|
||||
case 3:
|
||||
logger("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']);
|
||||
Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']);
|
||||
imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID);
|
||||
if ($mailconf['movetofolder'] != "") {
|
||||
imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID);
|
||||
|
@ -575,18 +576,18 @@ class OnePoll
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger("Mail: no mails for ".$mailconf['user']);
|
||||
Logger::log("Mail: no mails for ".$mailconf['user']);
|
||||
}
|
||||
|
||||
logger("Mail: closing connection for ".$mailconf['user']);
|
||||
Logger::log("Mail: closing connection for ".$mailconf['user']);
|
||||
imap_close($mbox);
|
||||
}
|
||||
}
|
||||
|
||||
if ($xml) {
|
||||
logger('received xml : ' . $xml, LOGGER_DATA);
|
||||
Logger::log('received xml : ' . $xml, LOGGER_DATA);
|
||||
if (!strstr($xml, '<')) {
|
||||
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
Logger::log('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
|
||||
$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
|
||||
self::updateContact($contact, $fields);
|
||||
|
@ -595,7 +596,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
|
||||
logger("Consume feed of contact ".$contact['id']);
|
||||
Logger::log("Consume feed of contact ".$contact['id']);
|
||||
|
||||
consume_feed($xml, $importer, $contact, $hub);
|
||||
|
||||
|
@ -617,10 +618,10 @@ class OnePoll
|
|||
$hub_update = true;
|
||||
}
|
||||
|
||||
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
|
||||
Logger::log("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
|
||||
|
||||
if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == Protocol::FEED)) {
|
||||
logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
Logger::log('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
$hubs = explode(',', $hub);
|
||||
|
||||
if (count($hubs)) {
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Core\Worker;
|
||||
|
||||
class ProfileUpdate {
|
||||
public static function execute($uid = 0) {
|
||||
|
@ -22,7 +23,7 @@ class ProfileUpdate {
|
|||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid);
|
||||
|
||||
foreach ($inboxes as $inbox) {
|
||||
logger('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'APDelivery', Delivery::PROFILEUPDATE, '', $inbox, $uid);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\PushSubscriber;
|
||||
|
@ -37,7 +38,7 @@ class PubSubPublish
|
|||
/// @todo Check server status with PortableContact::checkServer()
|
||||
// Before this can be done we need a way to safely detect the server url.
|
||||
|
||||
logger("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], LOGGER_DEBUG);
|
||||
Logger::log("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], LOGGER_DEBUG);
|
||||
|
||||
$last_update = $subscriber['last_update'];
|
||||
$params = OStatus::feed($subscriber['nickname'], $last_update);
|
||||
|
@ -54,7 +55,7 @@ class PubSubPublish
|
|||
$subscriber['topic']),
|
||||
"X-Hub-Signature: sha1=" . $hmac_sig];
|
||||
|
||||
logger('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DATA);
|
||||
Logger::log('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DATA);
|
||||
|
||||
$postResult = Network::post($subscriber['callback_url'], $params, $headers);
|
||||
$ret = $postResult->getReturnCode();
|
||||
|
@ -62,11 +63,11 @@ class PubSubPublish
|
|||
$condition = ['id' => $subscriber['id']];
|
||||
|
||||
if ($ret >= 200 && $ret <= 299) {
|
||||
logger('Successfully pushed to ' . $subscriber['callback_url']);
|
||||
Logger::log('Successfully pushed to ' . $subscriber['callback_url']);
|
||||
|
||||
PushSubscriber::reset($subscriber['id'], $last_update);
|
||||
} else {
|
||||
logger('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret);
|
||||
Logger::log('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret);
|
||||
|
||||
PushSubscriber::delay($subscriber['id']);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -32,7 +33,7 @@ class Queue
|
|||
$no_dead_check = Config::get('system', 'queue_no_dead_check', false);
|
||||
|
||||
if (!$queue_id) {
|
||||
logger('filling queue jobs - start');
|
||||
Logger::log('filling queue jobs - start');
|
||||
|
||||
// Handling the pubsubhubbub requests
|
||||
PushSubscriber::requeue();
|
||||
|
@ -43,11 +44,11 @@ class Queue
|
|||
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $q_item) {
|
||||
logger('Call queue for id ' . $q_item['id']);
|
||||
Logger::log('Call queue for id ' . $q_item['id']);
|
||||
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Queue", (int) $q_item['id']);
|
||||
}
|
||||
}
|
||||
logger('filling queue jobs - end');
|
||||
Logger::log('filling queue jobs - end');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ class Queue
|
|||
$dead = Cache::get($cachekey_deadguy . $contact['notify']);
|
||||
|
||||
if (!is_null($dead) && $dead && !$no_dead_check) {
|
||||
logger('queue: skipping known dead url: ' . $contact['notify']);
|
||||
Logger::log('queue: skipping known dead url: ' . $contact['notify']);
|
||||
QueueModel::updateTime($q_item['id']);
|
||||
return;
|
||||
}
|
||||
|
@ -84,14 +85,14 @@ class Queue
|
|||
$vital = Cache::get($cachekey_server . $server);
|
||||
|
||||
if (is_null($vital)) {
|
||||
logger("Check server " . $server . " (" . $contact["network"] . ")");
|
||||
Logger::log("Check server " . $server . " (" . $contact["network"] . ")");
|
||||
|
||||
$vital = PortableContact::checkServer($server, $contact["network"], true);
|
||||
Cache::set($cachekey_server . $server, $vital, Cache::MINUTE);
|
||||
}
|
||||
|
||||
if (!is_null($vital) && !$vital) {
|
||||
logger('queue: skipping dead server: ' . $server);
|
||||
Logger::log('queue: skipping dead server: ' . $server);
|
||||
QueueModel::updateTime($q_item['id']);
|
||||
return;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ class Queue
|
|||
|
||||
switch ($contact['network']) {
|
||||
case Protocol::DFRN:
|
||||
logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
Logger::log('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = DFRN::deliver($owner, $contact, $data);
|
||||
|
||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||
|
@ -124,7 +125,7 @@ class Queue
|
|||
break;
|
||||
|
||||
case Protocol::OSTATUS:
|
||||
logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
Logger::log('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = Salmon::slapper($owner, $contact['notify'], $data);
|
||||
|
||||
if ($deliver_status == -1) {
|
||||
|
@ -136,7 +137,7 @@ class Queue
|
|||
break;
|
||||
|
||||
case Protocol::DIASPORA:
|
||||
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
Logger::log('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true);
|
||||
|
||||
if ((($deliver_status >= 200) && ($deliver_status <= 299)) ||
|
||||
|
@ -159,7 +160,7 @@ class Queue
|
|||
}
|
||||
break;
|
||||
}
|
||||
logger('Deliver status ' . (int)$deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
Logger::log('Deliver status ' . (int)$deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
*/
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
require_once("include/items.php");
|
||||
require_once "include/items.php";
|
||||
|
||||
class SpoolPost {
|
||||
public static function execute() {
|
||||
|
@ -49,7 +50,7 @@ class SpoolPost {
|
|||
|
||||
$result = Item::insert($arr);
|
||||
|
||||
logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);
|
||||
Logger::log("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);
|
||||
unlink($fullfile);
|
||||
}
|
||||
closedir($dh);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
class TagUpdate
|
||||
|
@ -10,7 +11,7 @@ class TagUpdate
|
|||
{
|
||||
$messages = DBA::p("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''");
|
||||
|
||||
logger('fetched messages: ' . DBA::numRows($messages));
|
||||
Logger::log('fetched messages: ' . DBA::numRows($messages));
|
||||
while ($message = DBA::fetch($messages)) {
|
||||
if ($message['uid'] == 0) {
|
||||
$global = true;
|
||||
|
@ -29,7 +30,7 @@ class TagUpdate
|
|||
|
||||
$messages = DBA::select('item', ['guid'], ['uid' => 0]);
|
||||
|
||||
logger('fetched messages: ' . DBA::numRows($messages));
|
||||
Logger::log('fetched messages: ' . DBA::numRows($messages));
|
||||
while ($message = DBA::fetch(messages)) {
|
||||
DBA::update('item', ['global' => true], ['guid' => $message['guid']]);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\Probe;
|
||||
|
@ -16,10 +17,10 @@ class UpdateGContact
|
|||
{
|
||||
public static function execute($contact_id)
|
||||
{
|
||||
logger('update_gcontact: start');
|
||||
Logger::log('update_gcontact: start');
|
||||
|
||||
if (empty($contact_id)) {
|
||||
logger('update_gcontact: no contact');
|
||||
Logger::log('update_gcontact: no contact');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue