aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-07-22 18:57:48 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-07-22 19:02:45 -0700
commitc0e67db070ae562f8e717a12faf5df9ecd7160d6 (patch)
tree59d401819fb12ec5e14257ba3df4851d22aa0b8c /include/network.php
parentc90f14c066d0f289bd2220bb66325db12700aa57 (diff)
downloadvolse-hubzilla-c0e67db070ae562f8e717a12faf5df9ecd7160d6.tar.gz
volse-hubzilla-c0e67db070ae562f8e717a12faf5df9ecd7160d6.tar.bz2
volse-hubzilla-c0e67db070ae562f8e717a12faf5df9ecd7160d6.zip
refresh diaspora xchan every month or so since receiving profile update messages from that network reliably are just as unlikely as receiving any other kind of message from that network reliably. The problem is that if somebody changes their profile name or photo once every few years and you miss it because of their shitty unreliable communications, your data could be stale for a long time.
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/include/network.php b/include/network.php
index 5173bc3d0..5d01b7eba 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1135,9 +1135,27 @@ function discover_by_webbie($webbie) {
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
- dbesc($webbie)
+ dbesc($addr)
);
- if(! $r) {
+
+ /**
+ *
+ * Diaspora communications are notoriously unreliable and receiving profile update messages (indeed any messages)
+ * are pretty much random luck. We'll check the timestamp of the xchan_name_date at a higher level and refresh
+ * this record once a month; because if you miss a profile update message and they update their profile photo or name
+ * you're otherwise stuck with stale info until they change their profile again - which could be years from now.
+ *
+ */
+
+ if($r) {
+ $r = q("update xchan set xchan_name = '%s', xchan_network = '%s', xchan_name_date = '%s' where xchan_hash = '%s' limit 1",
+ dbesc($vcard['fn']),
+ dbesc($network),
+ dbesc(datetime_convert()),
+ dbesc($addr)
+ );
+ }
+ else {
$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
dbesc($addr),