aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php64
1 files changed, 46 insertions, 18 deletions
diff --git a/include/network.php b/include/network.php
index d9546a074..e1793b405 100644
--- a/include/network.php
+++ b/include/network.php
@@ -586,7 +586,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
if(substr($mtch[1],0,1) == '=') {
$owidth = intval(substr($mtch[2],1));
- if(intval($owidth) > 0 && intval($owidth) < 640)
+ if(intval($owidth) > 0 && intval($owidth) < 1024)
continue;
}
@@ -624,9 +624,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$orig_width = $ph->getWidth();
$orig_height = $ph->getHeight();
- if($orig_width > 640 || $orig_height > 640) {
+ if($orig_width > 1024 || $orig_height > 1024) {
$tag = (($match[1] == 'z') ? 'zmg' : 'img');
- $ph->scaleImage(640);
+ $ph->scaleImage(1024);
$new_width = $ph->getWidth();
$new_height = $ph->getHeight();
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
@@ -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]),
@@ -1053,21 +1053,30 @@ function discover_by_webbie($webbie) {
$webbie = strtolower($webbie);
- $x = webfinger_rfc7033($webbie);
+ $x = webfinger_rfc7033($webbie,true);
if($x && array_key_exists('links',$x) && $x['links']) {
foreach($x['links'] as $link) {
if(array_key_exists('rel',$link) && $link['rel'] == 'http://purl.org/zot/protocol') {
logger('discover_by_webbie: zot found for ' . $webbie, LOGGER_DEBUG);
- $z = z_fetch_url($link['href']);
- if($z['success']) {
- $j = json_decode($z['body'],true);
- $i = import_xchan($j);
- return true;
+ if(array_key_exists('zot',$x) && $x['zot']['success'])
+ $i = import_xchan($x['zot']);
+ else {
+ $z = z_fetch_url($link['href']);
+ if($z['success']) {
+ $j = json_decode($z['body'],true);
+ $i = import_xchan($j);
+ return true;
+ }
}
}
}
}
+ $arr = array('address' => $webbie, 'success' => false);
+ call_hooks('discover_by_webbie', $arr);
+ if($arr['success'])
+ return true;
+
$result = array();
$network = null;
$diaspora = false;
@@ -1132,12 +1141,32 @@ function discover_by_webbie($webbie) {
if($hcard) {
$vcard = scrape_vcard($hcard);
$vcard['nick'] = substr($webbie,0,strpos($webbie,'@'));
+ if(! $vcard['fn'])
+ $vcard['fn'] = $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 +1187,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 +1195,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]),
@@ -1258,7 +1286,7 @@ LSIeXnd14lQYK/uxW/8cTFjcmddsKxeXysoQxbSa9VdDK+KkpZdgYXYrTTofXs6v+
}
-function webfinger_rfc7033($webbie) {
+function webfinger_rfc7033($webbie,$zot = false) {
if(! strpos($webbie,'@'))
@@ -1268,7 +1296,7 @@ function webfinger_rfc7033($webbie) {
$resource = 'acct:' . $webbie;
- $s = z_fetch_url('https://' . $rhs . '/.well-known/webfinger?resource=' . $resource);
+ $s = z_fetch_url('https://' . $rhs . '/.well-known/webfinger?f=&resource=' . $resource . (($zot) ? '&zot=1' : ''));
if($s['success'])
$j = json_decode($s['body'],true);