diff options
-rw-r--r-- | Zotlabs/Daemon/Channel_purge.php | 34 | ||||
-rw-r--r-- | include/channel.php | 12 |
2 files changed, 39 insertions, 7 deletions
diff --git a/Zotlabs/Daemon/Channel_purge.php b/Zotlabs/Daemon/Channel_purge.php new file mode 100644 index 000000000..416126896 --- /dev/null +++ b/Zotlabs/Daemon/Channel_purge.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Daemon; + +class Channel_purge { + + static public function run($argc,$argv) { + + cli_startup(); + + $channel_id = intval($argv[1]); + + $channel = q("select * from channel where channel_id = %d and channel_removed = 1", + intval($channel_id) + ); + + if (! $channel) { + return; + } + + do { + $r = q("select id from item where uid = %d and item_deleted = 0 limit 100", + intval($channel_id) + ); + if ($r) { + foreach ($r as $rv) { + drop_item($rv['id'],false); + } + } + } while ($r); + + return; + } +} diff --git a/include/channel.php b/include/channel.php index 53b781eb6..ca6d01498 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2825,13 +2825,6 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { } } - $r = q("select id from item where uid = %d", intval($channel_id)); - if($r) { - foreach($r as $rv) { - drop_item($rv['id'],false); - } - } - q("delete from abook where abook_xchan = '%s' and abook_self = 1 ", dbesc($channel['channel_hash']) ); @@ -2841,6 +2834,9 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { intval($channel_id) ); + // remove items + Master::Summon([ 'Channel_purge', $channel_id ]); + // if this was the default channel, set another one as default if(App::$account['account_default_channel'] == $channel_id) { $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", @@ -2881,6 +2877,8 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s'", dbesc($channel['channel_hash']) ); + // send a cleanup message to other servers + Master::Summon([ 'Notifier', 'purge_all', $channel_id ]); } //remove from file system |