aboutsummaryrefslogtreecommitdiffstats
path: root/include/hubloc.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-09-13 16:00:09 -0700
committerfriendica <info@friendica.com>2014-09-13 16:00:09 -0700
commit0350b76d851977ccd6eed4278738346f0febbf96 (patch)
tree1e7201556aad613a5498ad8893e0d968f19897de /include/hubloc.php
parentb1809f5f0c14f15cb3caf74229bb12e3d544c9f9 (diff)
downloadvolse-hubzilla-0350b76d851977ccd6eed4278738346f0febbf96.tar.gz
volse-hubzilla-0350b76d851977ccd6eed4278738346f0febbf96.tar.bz2
volse-hubzilla-0350b76d851977ccd6eed4278738346f0febbf96.zip
some backend work for the remaining missing bits of mod_hubman - this is still a fair ways from being complete and is not ready for prime time. Basically we'll let a channel send out a public message saying "these are my currently approved locations" and anything that isn't in the list will be marked deleted. We'll send out this message when locations change somehow - either through direct personal involvement (hub revoke, change primary, channel import) or during a system rename or "find bad/obsolete hublocs" activity. This way we won't have clones sending back location info we just got rid of and re-importing the bad entries.
Diffstat (limited to 'include/hubloc.php')
-rw-r--r--include/hubloc.php56
1 files changed, 55 insertions, 1 deletions
diff --git a/include/hubloc.php b/include/hubloc.php
index 566875ce9..d51e38eae 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -42,4 +42,58 @@ function prune_hub_reinstalls() {
}
}
}
-} \ No newline at end of file
+}
+
+function remove_obsolete_hublocs() {
+
+ // Get rid of any hublocs which are ours but aren't valid anymore -
+ // e.g. they point to a different and perhaps transient URL that we aren't using.
+
+ // I need to stress that this shouldn't happen. fix_system_urls() fixes hublocs
+ // when it discovers the URL has changed. So it's unclear how we could end up
+ // with URLs pointing to the old site name. But it happens. This may be an artifact
+ // of an old bug or maybe a regression in some newer code. In any event, they
+ // mess up communications and we have to take action if we find any.
+
+ // First make sure we have any hublocs (at all) with this URL and sitekey.
+ // We don't want to perform this operation while somebody is in the process
+ // of renaming their hub or installing certs.
+
+ $r = q("select hubloc_id from hubloc where hubloc_url = '%s' and hubloc_sitekey = '%s'",
+ dbesc(z_root()),
+ dbesc(get_config('system','pubkey'))
+ );
+ if((! $r) || (! count($r)))
+ return;
+
+ // Good. We have at least one valid hubloc.
+
+ // Do we have any invalid ones?
+
+ $r = q("select hubloc_id from hubloc where hubloc_sitekey = '%s' and hubloc_url != '%s'",
+ dbesc(get_config('system','pubkey')),
+ dbesc(z_root())
+ );
+ if(! $r)
+ return;
+
+ logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.');
+
+ // We've got invalid hublocs. Get rid of them.
+
+ $r = q("delete from hubloc where hubloc_sitekey = '%s' and hubloc_url != '%s'",
+ dbesc(get_config('system','pubkey')),
+ dbesc(z_root())
+ );
+
+ // We should probably tell everybody... But we don't have an easy way to do this
+ // for the entire site. We'd have to do a channel at a time.
+ // They will find out anyway - it just might take a little while.
+
+ // FIXME we probably also need to check that the sys channel has a valid hubloc
+ // and re-create it if it doesn't.
+
+}
+
+
+ \ No newline at end of file