aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon')
-rw-r--r--Zotlabs/Daemon/Cron.php12
-rw-r--r--Zotlabs/Daemon/Cron_daily.php11
-rw-r--r--Zotlabs/Daemon/Expire.php7
-rw-r--r--Zotlabs/Daemon/Onedirsync.php48
-rw-r--r--Zotlabs/Daemon/Onepoll.php12
-rw-r--r--Zotlabs/Daemon/Poller.php36
-rw-r--r--Zotlabs/Daemon/Queue.php17
-rw-r--r--Zotlabs/Daemon/Zotconvo.php32
8 files changed, 86 insertions, 89 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 640f06102..caae0ce53 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libsync;
+use Zotlabs\Lib\Libzotdir;
class Cron {
@@ -35,6 +36,17 @@ class Cron {
logger('cron: start');
+ // If this is a directory server, request a sync with an upstream
+ // directory at least once a day, up to once every poll interval.
+ // Pull remote changes and push local changes.
+ // potential issue: how do we keep from creating an endless update loop?
+
+ $dirmode = get_config('system', 'directory_mode');
+
+ if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
+ Libzotdir::sync_directories($dirmode);
+ }
+
// run queue delivery process in the background
Master::Summon(array('Queue'));
diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php
index 6d62836c7..850d38229 100644
--- a/Zotlabs/Daemon/Cron_daily.php
+++ b/Zotlabs/Daemon/Cron_daily.php
@@ -94,17 +94,6 @@ class Cron_daily {
// expire any expired accounts
downgrade_accounts();
- // If this is a directory server, request a sync with an upstream
- // directory at least once a day, up to once every poll interval.
- // Pull remote changes and push local changes.
- // potential issue: how do we keep from creating an endless update loop?
-
- $dirmode = get_config('system', 'directory_mode');
-
- if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
- Libzotdir::sync_directories($dirmode);
- }
-
Master::Summon(array('Expire'));
Master::Summon(array('Cli_suggest'));
diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php
index 5d9f14b28..84a606dc2 100644
--- a/Zotlabs/Daemon/Expire.php
+++ b/Zotlabs/Daemon/Expire.php
@@ -32,7 +32,6 @@ class Expire {
}
// physically remove anything that has been deleted for more than two months
- /** @FIXME - this is a wretchedly inefficient query */
q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
db_utcnow(),
@@ -59,8 +58,8 @@ class Expire {
continue;
// service class default (if non-zero) over-rides the site default
-
$service_class_expire = service_class_fetch($rr['channel_id'], 'expire_days');
+
if (intval($service_class_expire))
$channel_expire = $service_class_expire;
else
@@ -85,7 +84,6 @@ class Expire {
// this should probably just fetch the channel_expire_days from the sys channel,
// but there's no convenient way to set it.
-
$expire_days = get_config('system', 'sys_expire_days');
if ($expire_days === false)
$expire_days = 30;
@@ -96,8 +94,9 @@ class Expire {
logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
- if ($expire_days)
+ if ($expire_days) {
item_expire($x['channel_id'], $expire_days, $commented_days);
+ }
logger('Expire: sys: done', LOGGER_DEBUG);
}
diff --git a/Zotlabs/Daemon/Onedirsync.php b/Zotlabs/Daemon/Onedirsync.php
index ea995be9e..b711b0c05 100644
--- a/Zotlabs/Daemon/Onedirsync.php
+++ b/Zotlabs/Daemon/Onedirsync.php
@@ -15,61 +15,45 @@ class Onedirsync {
$update_id = intval($argv[1]);
if (!$update_id) {
- logger('onedirsync: no update');
+ logger('onedirsync: no update id');
return;
}
- $r = q("select * from updates where ud_id = %d limit 1",
+ $r = q("select * from updates where ud_id = %d",
intval($update_id)
);
- if (!$r)
- return;
-
- if (($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED) || (!$r[0]['ud_addr']))
- return;
-
- // Have we probed this channel more recently than the other directory server
- // (where we received this update from) ?
- // If we have, we don't need to do anything except mark any older entries updated
-
- $x = q("select * from updates where ud_addr = '%s' and ud_date > '%s' and ( ud_flags & %d )>0 order by ud_date desc limit 1",
- dbesc($r[0]['ud_addr']),
- dbesc($r[0]['ud_date']),
- intval(UPDATE_FLAGS_UPDATED)
- );
- if ($x) {
- q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date != '%s'",
- intval(UPDATE_FLAGS_UPDATED),
- dbesc($r[0]['ud_addr']),
- intval(UPDATE_FLAGS_UPDATED),
- dbesc($x[0]['ud_date'])
- );
+ if (!$r) {
+ logger('onedirsync: update id not found');
return;
}
// ignore doing an update if this ud_addr refers to a known dead hubloc
- $h = q("select * from hubloc where hubloc_addr = '%s'",
+ $h = q("select * from hubloc where hubloc_id_url = '%s' order by hubloc_id desc",
dbesc($r[0]['ud_addr']),
);
$h = Libzot::zot_record_preferred($h);
if (($h) && (($h['hubloc_status'] & HUBLOC_OFFLINE) || $h['hubloc_deleted'] || $h['hubloc_error'])) {
- q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 ",
- intval(UPDATE_FLAGS_DELETED),
- dbesc($r[0]['ud_addr']),
- intval(UPDATE_FLAGS_UPDATED)
- );
- return;
+
+ // 2023-04-12: Try to update anyway since the info is not always correct
+ // This might change after all directory servers run the new code.
+
+ // q("update updates set ud_flags = 9 where ud_hash = '%s' and ud_flags != 9",
+ // dbesc($r[0]['ud_hash'])
+ //);
+
+ // return;
}
// we might have to pull this out some day, but for now update_directory_entry()
// runs zot_finger() and is kind of zot specific
- if ($h && $h['hubloc_network'] !== 'zot6')
+ if ($h && $h['hubloc_network'] !== 'zot6') {
return;
+ }
Libzotdir::update_directory_entry($r[0]);
diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php
index bde39007e..973bcf402 100644
--- a/Zotlabs/Daemon/Onepoll.php
+++ b/Zotlabs/Daemon/Onepoll.php
@@ -30,14 +30,10 @@ class Onepoll {
$sql_extra = ' and abook_feed = 0 ';
}
- $contacts = q("SELECT abook.*, xchan.*, account.*
- FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan
- where abook_id = %d $sql_extra
- and abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0
- AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1",
- intval($contact_id),
- intval(ACCOUNT_OK),
- intval(ACCOUNT_UNVERIFIED)
+ $contacts = q("SELECT abook.*, xchan.* FROM abook
+ LEFT JOIN xchan ON xchan_hash = abook_xchan
+ WHERE abook_id = %d",
+ intval($contact_id)
);
if (!$contacts) {
diff --git a/Zotlabs/Daemon/Poller.php b/Zotlabs/Daemon/Poller.php
index 0fdc3da16..77a428ec3 100644
--- a/Zotlabs/Daemon/Poller.php
+++ b/Zotlabs/Daemon/Poller.php
@@ -19,24 +19,6 @@ class Poller {
$interval = get_config('queueworker', 'queue_interval', 500000);
-/*
- if (!$interval) {
- $interval = ((get_config('system', 'delivery_interval') === false) ? 3 : intval(get_config('system', 'delivery_interval')));
- }
-
- // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
- $lockfile = 'store/[data]/poller';
- if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
- && (!get_config('system', 'override_poll_lockfile'))) {
- logger("poller: Already running");
- return;
- }
-
- // Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
- $x = '';
- file_put_contents($lockfile, $x);
-*/
-
logger('poller: start');
$manual_id = 0;
@@ -67,6 +49,11 @@ class Poller {
: ''
);
+ $allow_feeds = get_config('system', 'feed_contacts');
+ if(!$allow_feeds) {
+ $sql_extra .= ' and abook_feed = 0 ';
+ }
+
$randfunc = db_getfunc('RAND');
$contacts = q("SELECT abook.abook_updated, abook.abook_connected, abook.abook_feed,
@@ -76,7 +63,7 @@ class Poller {
account.account_lastlog, account.account_flags
FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash
LEFT JOIN account on abook_account = account_id
- where abook_self = 0
+ where abook_self = 0 and abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0
$sql_extra
AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY $randfunc",
intval(ACCOUNT_OK),
@@ -183,11 +170,12 @@ class Poller {
$dirmode = intval(get_config('system', 'directory_mode'));
if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
- $r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last <= '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ",
- intval(UPDATE_FLAGS_UPDATED),
+ $r = q("SELECT * FROM updates WHERE ud_update = 1 AND (ud_last = '%s' OR ud_last > %s - INTERVAL %s)",
dbesc(NULL_DATE),
- db_utcnow(), db_quoteinterval('7 DAY')
+ db_utcnow(),
+ db_quoteinterval('7 DAY')
);
+
if ($r) {
foreach ($r as $rr) {
@@ -209,10 +197,6 @@ class Poller {
set_config('system', 'lastpoll', datetime_convert());
- //All done - clear the lockfile
-/*
- @unlink($lockfile);
-*/
return;
}
}
diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php
index b07fe369c..91aba831a 100644
--- a/Zotlabs/Daemon/Queue.php
+++ b/Zotlabs/Daemon/Queue.php
@@ -14,7 +14,7 @@ class Queue {
// delete all queue items more than 3 days old
// but first mark these sites dead if we haven't heard from them in a month
- $oldqItems = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
+ $oldqItems = q("select outq_posturl, outq_hash from outq where outq_created < %s - INTERVAL %s",
db_utcnow(),
db_quoteinterval('3 DAY')
);
@@ -29,13 +29,13 @@ class Queue {
db_quoteinterval('1 MONTH')
);
}
- }
- logger('Removing ' . count($oldqItems) . ' old queue entries');
- q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
- db_utcnow(),
- db_quoteinterval('3 DAY')
- );
+ $old_hashes = ids_to_querystr($oldqItems, 'outq_hash', true);
+
+ logger('Removing ' . count($oldqItems) . ' old queue entries');
+ dbq("DELETE FROM outq WHERE outq_hash IN ($old_hashes)");
+
+ }
$deliveries = [];
@@ -47,9 +47,10 @@ class Queue {
LibQueue::deliver($qItems[0]);
}
else {
- $qItems = q("SELECT * FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s ",
+ $qItems = q("SELECT outq_hash FROM outq WHERE outq_scheduled < %s ",
db_utcnow()
);
+
if ($qItems) {
foreach ($qItems as $qItem) {
$deliveries[] = $qItem['outq_hash'];
diff --git a/Zotlabs/Daemon/Zotconvo.php b/Zotlabs/Daemon/Zotconvo.php
new file mode 100644
index 000000000..16e7f113f
--- /dev/null
+++ b/Zotlabs/Daemon/Zotconvo.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Zotlabs\Daemon;
+
+use Zotlabs\Lib\Libzot;
+
+class Zotconvo {
+
+ static public function run($argc, $argv) {
+
+ logger('Zotconvo invoked: ' . print_r($argv, true));
+
+ if ($argc != 3) {
+ return;
+ }
+
+ $mid = $argv[2];
+ if (!$mid) {
+ return;
+ }
+
+ $channel = channelx_by_n(intval($argv[1]));
+ if (!$channel) {
+ return;
+ }
+
+ Libzot::fetch_conversation($channel, $mid);
+
+ return;
+
+ }
+}