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.

This commit is contained in:
redmatrix 2015-07-22 18:57:48 -07:00
parent c90f14c066
commit c0e67db070
3 changed files with 36 additions and 4 deletions

View file

@ -329,6 +329,7 @@ function diaspora_get_contact_by_handle($uid,$handle) {
function find_diaspora_person_by_handle($handle) {
$person = false;
$refresh = false;
if(diaspora_is_blacklisted($handle))
return false;
@ -339,9 +340,13 @@ function find_diaspora_person_by_handle($handle) {
if($r) {
$person = $r[0];
logger('find_diaspora_person_by handle: in cache ' . print_r($r,true), LOGGER_DATA);
if($person['xchan_name_date'] < datetime_convert('UTC','UTC', 'now - 1 month')) {
logger('Updating Diaspora cached record for ' . $handle);
$refresh = true;
}
}
if(! $person) {
if((! $person) || ($refresh)) {
// try webfinger. Make sure to distinguish between diaspora,
// hubzilla w/diaspora protocol and friendica w/diaspora protocol.
@ -349,7 +354,7 @@ function find_diaspora_person_by_handle($handle) {
$result = discover_by_webbie($handle);
if($result) {
$r = q("select * from xchan where xchan_addr = '%s' limit 1",
dbesc($handle)
dbesc(str_replace('acct:','',$handle))
);
if($r) {
$person = $r[0];
@ -1003,6 +1008,11 @@ function diaspora_post($importer,$xml,$msg) {
return 202;
}
if(! is_importable($datarray,$contact)) {
logger('diaspora_post: filtering this author.');
return 202;
}
$result = item_store($datarray);
return;

View file

@ -3766,6 +3766,10 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$author['owner_avatar'] = $contact['thumb'];
}
if(! is_importable($datarray,$contact))
continue;
logger('consume_feed: author ' . print_r($author,true),LOGGER_DEBUG);
logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA);

View file

@ -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),