diff options
Diffstat (limited to 'include/network.php')
-rw-r--r-- | include/network.php | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/include/network.php b/include/network.php index d9546a074..75729d6e4 100644 --- a/include/network.php +++ b/include/network.php @@ -1035,7 +1035,7 @@ function discover_by_url($url,$arr = null) { dbesc(datetime_convert()) ); - $photos = import_profile_photo($photo,$guid); + $photos = import_xchan_photo($photo,$guid); $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($photos[0]), @@ -1068,6 +1068,11 @@ function discover_by_webbie($webbie) { } } + $arr = array('address' => $webbie, 'success' => false); + call_hooks('discover_by_webbie', $arr); + if($arr['success']) + return true; + $result = array(); $network = null; $diaspora = false; @@ -1135,9 +1140,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), @@ -1158,7 +1181,7 @@ function discover_by_webbie($webbie) { if(! $r) { - $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_flags ) values ('%s','%s','%s','%s','%s','%s','%s','%s', %d)", + $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_primary ) values ('%s','%s','%s','%s','%s','%s','%s','%s', 1)", dbesc($guid), dbesc($addr), dbesc($addr), @@ -1166,11 +1189,10 @@ function discover_by_webbie($webbie) { dbesc(trim($diaspora_base,'/')), dbesc($hostname), dbesc($notify), - dbescdate(datetime_convert()), - intval(HUBLOC_FLAGS_PRIMARY) + dbescdate(datetime_convert()) ); } - $photos = import_profile_photo($vcard['photo'],$addr); + $photos = import_xchan_photo($vcard['photo'],$addr); $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbescdate(datetime_convert('UTC','UTC',$arr['photo_updated'])), dbesc($photos[0]), |