Commit b10c188a authored by Mario's avatar Mario

Merge branch 'patch-2' into 'dev'

Fix for Diaspora profile data intelligent updating

See merge request hubzilla/addons!155
parents c1e09421 6dd0dd17
......@@ -1803,7 +1803,7 @@ class Diaspora_Receiver {
}
$image_url = unxmlify($this->xmlbase['image_url']);
$birthday = unxmlify($this->xmlbase['birthday']);
$edited = datetime_convert('UTC','UTC',$this->xmlbase['edited_at']);
$handle_parts = explode("@", $diaspora_handle);
if($name === '') {
......@@ -1815,8 +1815,25 @@ class Diaspora_Receiver {
}
require_once('include/photo/photo_driver.php');
$images = import_xchan_photo($image_url,$contact['xchan_hash']);
if($edited > $contact['xchan_photo_date']) {
$images = import_xchan_photo($image_url,$contact['xchan_hash']);
$newimg = true;
} else {
$images = array($contact['xchan_photo_l'],$contact['xchan_photo_m'],$contact['xchan_photo_s'],$contact['xchan_photo_mimetype']);
$newimg = false;
}
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', 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($name),
dbesc(($name != $contact['xchan_name'] ? $edited : $contact['xchan_name_date'])),
dbesc(($newimg ? $edited : $contact['xchan_photo_date'])),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc($contact['xchan_hash'])
);
// Somebody is sending us birthday arrays.
......@@ -1846,17 +1863,6 @@ class Diaspora_Receiver {
// if(substr($birthday,5) === substr($contact['bd'],5))
// $birthday = $contact['bd'];
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' ",
dbesc($name),
dbesc(datetime_convert()),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc(datetime_convert()),
intval($contact['xchan_hash'])
);
return;
}
......@@ -2303,15 +2309,15 @@ class Diaspora_Receiver {
if(substr($birthday,5) === substr($new_contact['bd'],5))
$birthday = $new_contact['bd'];
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' ",
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', 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($name),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc(datetime_convert()),
intval($new_contact['xchan_hash'])
dbesc($new_contact['xchan_hash'])
);
$r = q("update abook set abook_xchan = '%s' where abook_xchan = '%s' and abook_channel = %d",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment