aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Daemon/Cron.php2
-rw-r--r--Zotlabs/Daemon/Cron_weekly.php15
-rw-r--r--include/channel.php60
3 files changed, 61 insertions, 16 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 65edbedfa..01c43262a 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -78,7 +78,7 @@ class Cron {
// channels and sites that quietly vanished and prevent the directory from accumulating stale
// or dead entries.
- $r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s",
+ $r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0",
db_utcnow(),
db_quoteinterval('30 DAY')
);
diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php
index 5b185f475..d44400767 100644
--- a/Zotlabs/Daemon/Cron_weekly.php
+++ b/Zotlabs/Daemon/Cron_weekly.php
@@ -21,6 +21,21 @@ class Cron_weekly {
mark_orphan_hubsxchans();
+ // Find channels that were removed in the last three weeks, but
+ // haven't been finally cleaned up. These should be older than 10
+ // days to ensure that "purgeall" messages have gone out or bounced
+ // or timed out.
+
+ $r = q("select channel_id from channel where channel_removed = 1 and
+ channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s",
+ db_utcnow(), db_quoteinterval('21 DAY'),
+ db_utcnow(), db_quoteinterval('10 DAY')
+ );
+ if($r) {
+ foreach($r as $rv) {
+ channel_remove_final($rv['channel_id']);
+ }
+ }
// get rid of really old poco records
diff --git a/include/channel.php b/include/channel.php
index 6a6022aba..4f0e8ec6a 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -2527,19 +2527,43 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
}
+ q("DELETE FROM app WHERE app_channel = %d", intval($channel_id));
+ q("DELETE FROM atoken WHERE atoken_uid = %d", intval($channel_id));
+ q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id));
+ q("DELETE FROM conv WHERE uid = %d", intval($channel_id));
q("DELETE FROM groups WHERE uid = %d", intval($channel_id));
q("DELETE FROM group_member WHERE uid = %d", intval($channel_id));
q("DELETE FROM event WHERE uid = %d", intval($channel_id));
- q("DELETE FROM item WHERE uid = %d", intval($channel_id));
q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id));
+ q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id));
+ q("DELETE FROM menu_item WHERE mitem_channel_id = %d", intval($channel_id));
+
q("DELETE FROM notify WHERE uid = %d", intval($channel_id));
+ q("DELETE FROM obj WHERE obj_channel = %d", intval($channel_id));
+
+
q("DELETE FROM photo WHERE uid = %d", intval($channel_id));
q("DELETE FROM attach WHERE uid = %d", intval($channel_id));
q("DELETE FROM profile WHERE uid = %d", intval($channel_id));
- q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id));
+ q("DELETE FROM src WHERE src_channel_id = %d", intval($channel_id));
+
+ $r = q("select resource_id FROM attach WHERE uid = %d", intval($channel_id));
+ if($r) {
+ foreach($r as $rv) {
+ attach_delete($channel_id,$rv['resource_id']);
+ }
+ }
+
+
+
+ $r = q("select id from item where uid = %d", intval($channel_id));
+ if($r) {
+ foreach($r as $rv) {
+ drop_item($rv['id'],false);
+ }
+ }
- /// @FIXME At this stage we need to remove the file resources located under /store/$nickname
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
dbesc($channel['channel_hash'])
@@ -2593,19 +2617,11 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
//remove from file system
- $r = q("select channel_address from channel where channel_id = %d limit 1",
- intval($channel_id)
- );
- if($r) {
- $channel_address = $r[0]['channel_address'] ;
- }
- if($channel_address) {
- $f = 'store/' . $channel_address.'/';
- logger('delete '. $f);
- if(is_dir($f)) {
- @rrmdir($f);
- }
+
+ $f = 'store/' . $channel['channel_address'];
+ if(is_dir($f)) {
+ @rrmdir($f);
}
Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id));
@@ -2616,6 +2632,20 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
}
}
+// execute this at least a week after removing a channel
+
+function channel_remove_final($channel_id) {
+
+ q("delete from abook where abook_channel = %d", intval($channel_id));
+ q("delete from abconfig where chan = %d", intval($channel_id));
+ q("delete from pconfig where uid = %d", intval($channel_id));
+
+
+}
+
+
+
+
/**
* @brief This checks if a channel is allowed to publish executable code.
*