aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php59
-rw-r--r--include/notifier.php35
-rw-r--r--include/zot.php10
3 files changed, 84 insertions, 20 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 46d356f3f..b9e879bcf 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -147,7 +147,9 @@ function user_remove($uid) {
}
-function account_remove($account_id) {
+function account_remove($account_id,$local = true) {
+
+ logger('account_remove: ' . $account_id);
if(! intval($account_id)) {
logger('account_remove: no account.');
@@ -179,7 +181,7 @@ function account_remove($account_id) {
);
if($x) {
foreach($x as $xx) {
- channel_remove($xx['channel_id']);
+ channel_remove($xx['channel_id'],$local);
}
}
@@ -191,7 +193,7 @@ function account_remove($account_id) {
}
-function channel_remove($channel_id) {
+function channel_remove($channel_id, $local = true) {
if(! $channel_id)
return;
@@ -199,13 +201,38 @@ function channel_remove($channel_id) {
logger('Removing channel: ' . $channel_id);
$r = q("select * from channel where channel_id = %d limit 1", intval($channel_id));
+ if(! $r) {
+ logger('channel_remove: channel not found: ' . $channel_id);
+ return;
+ }
+
+ $channel = $r[0];
call_hooks('channel_remove',$r[0]);
+ if(! $local) {
+
// FIXME notify the directory
// FIXME notify all contacts
+ $r = q("update channel set channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0,
+ channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0,
+ channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0,
+ channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1",
+ intval(PAGE_REMOVED),
+ intval($channel_id)
+ );
+
+ $r = q("update hubloc set hubloc_flags = hubloc_flags | %d where hubloc_hash = '%s'",
+ intval(HUBLOC_FLAGS_DELETED),
+ dbesc($channel['channel_hash'])
+ );
+
+ proc_run('php','include/notifier.php','purge_all',$channel_id);
+
+
+ }
q("DELETE FROM `group` WHERE `uid` = %d", intval($channel_id));
q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id));
@@ -278,18 +305,20 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
);
- $r = q("delete from xchan where xchan_hash = '%s' limit 1",
- dbesc($xchan)
- );
- $r = q("delete from hubloc where hubloc_hash = '%s'",
- dbesc($xchan)
- );
- $r = q("delete from abook where abook_xchan = '%s'",
- dbesc($xchan)
- );
- $r = q("delete from xtag where xtag_hash = '%s'",
- dbesc($xchan)
- );
+// This could get sticky with directories
+
+// $r = q("delete from xchan where xchan_hash = '%s' limit 1",
+// dbesc($xchan)
+// );
+// $r = q("delete from hubloc where hubloc_hash = '%s'",
+// dbesc($xchan)
+// );
+// $r = q("delete from abook where abook_xchan = '%s'",
+// dbesc($xchan)
+// );
+// $r = q("delete from xtag where xtag_hash = '%s'",
+// dbesc($xchan)
+// );
}
}
diff --git a/include/notifier.php b/include/notifier.php
index e1f150bf2..0c7ac5264 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -54,6 +54,7 @@ require_once('include/html2plain.php');
* ZOT
* permission_update abook_id
* refresh_all channel_id
+ * purge_all channel_id
* expire channel_id
* relay item_id (item was relayed to owner, we will deliver it as owner)
*
@@ -219,6 +220,26 @@ function notifier_run($argv, $argc){
$private = false;
$packet_type = 'refresh';
}
+ elseif($cmd === 'purge_all') {
+ logger('notifier: purge_all: ' . $item_id);
+ $s = q("select * from channel where channel_id = %d limit 1",
+ intval($item_id)
+ );
+ if($s)
+ $channel = $s[0];
+ $uid = $item_id;
+ $recipients = array();
+ $r = q("select abook_xchan from abook where abook_channel = %d",
+ intval($item_id)
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $recipients[] = $rr['abook_xchan'];
+ }
+ }
+ $private = false;
+ $packet_type = 'purge';
+ }
else {
// Normal items
@@ -388,7 +409,7 @@ function notifier_run($argv, $argc){
$sql_extra = (($private) ? "" : " or hubloc_url = '" . z_root() . "' ");
- $r = q("select distinct hubloc_sitekey, hubloc_callback, hubloc_host from hubloc
+ $r = q("select distinct hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc
where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
if(! $r) {
logger('notifier: no hubs');
@@ -397,8 +418,12 @@ function notifier_run($argv, $argc){
$hubs = $r;
$hublist = array();
- foreach($hubs as $hub)
- $hublist[] = $hub['hubloc_host'];
+ foreach($hubs as $hub) {
+ // don't try to deliver to deleted hublocs
+ if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) {
+ $hublist[] = $hub['hubloc_host'];
+ }
+ }
logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist,true), LOGGER_DEBUG);
@@ -414,8 +439,8 @@ function notifier_run($argv, $argc){
foreach($hubs as $hub) {
$hash = random_string();
- if($packet_type === 'refresh') {
- $n = zot_build_packet($channel,'refresh');
+ if($packet_type === 'refresh' || $packet_type === 'purge') {
+ $n = zot_build_packet($channel,$packet_type);
q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($hash),
intval($channel['channel_account']),
diff --git a/include/zot.php b/include/zot.php
index 0f42ddc7f..74ac6d015 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -610,6 +610,16 @@ function import_xchan($arr) {
$what = 'primary_hub ';
$changed = true;
}
+ if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted']))
+ || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) {
+ $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_id = %d limit 1",
+ intval(HUBLOC_FLAGS_DELETED),
+ dbesc(datetime_convert()),
+ intval($r[0]['hubloc_id'])
+ );
+ $what = 'delete_hub ';
+ $changed = true;
+ }
continue;
}