1
0
Fork 0

Merge pull request #2638 from annando/1606-avatar-handling

Imrpoved avatar handling when storing them/partly use of "micro"
This commit is contained in:
Tobias Diekershoff 2016-06-25 19:51:00 +02:00 committed by GitHub
commit 773517a734
8 changed files with 43 additions and 24 deletions

View file

@ -209,21 +209,21 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
// Fetch contact data from the contact table for the given user
$r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
`keywords`, `gender`, `photo`, `thumb`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
dbesc(normalise_link($url)), intval($uid));
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
if (!$r)
$r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
`keywords`, `gender`, `photo`, `thumb`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
dbesc(normalise_link($url)));
// Fetch the data from the gcontact table
if (!$r)
$r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($url)));
@ -267,9 +267,12 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
if (($profile["network"] == "") AND isset($default["network"]))
$profile["network"] = $default["network"];
if (!isset($profile["thumb"]) AND isset($profile["photo"]))
if (($profile["thumb"] == "") AND isset($profile["photo"]))
$profile["thumb"] = $profile["photo"];
if (($profile["micro"] == "") AND isset($profile["thumb"]))
$profile["micro"] = $profile["thumb"];
if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
proc_run('php',"include/update_gcontact.php", $profile["gid"]);

View file

@ -428,8 +428,8 @@ function bb_ShareAttributes($share, $simplehtml) {
if (isset($data["name"]))
$author = $data["name"];
if (isset($data["thumb"]))
$avatar = $data["thumb"];
if (isset($data["micro"]))
$avatar = $data["micro"];
$preshare = trim($share[1]);

View file

@ -1809,6 +1809,8 @@ class diaspora {
if(intval($def_gid))
group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
update_contact_avatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
if($importer["page-flags"] == PAGE_NORMAL) {
$hash = random_string().(string)time(); // Generate a confirm_key

View file

@ -1404,16 +1404,8 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
dbesc($url)
);
if(count($r)) {
$contact_record = $r[0];
$photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
intval($contact_record["id"])
);
$contact_record = $r[0];
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
}

View file

@ -388,17 +388,30 @@ function notifier_run(&$argv, &$argc){
// We have not only to look at the parent, since it could be a Friendica thread.
if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent[0]['author-link']." - Owner: ".$thr_parent[0]['owner-link'], LOGGER_DEBUG);
// Send a salmon to the parent author
$probed_contact = probe_url($thr_parent[0]['author-link']);
$r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
dbesc(normalise_link($thr_parent[0]['author-link'])),
intval($uid));
if ($r)
$probed_contact = $r[0];
else
$probed_contact = probe_url($thr_parent[0]['author-link']);
if ($probed_contact["notify"] != "") {
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
// Send a salmon to the parent owner
$probed_contact = probe_url($thr_parent[0]['owner-link']);
$r = q("SELECT `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
dbesc(normalise_link($thr_parent[0]['owner-link'])),
intval($uid));
if ($r)
$probed_contact = $r[0];
else
$probed_contact = probe_url($thr_parent[0]['owner-link']);
if ($probed_contact["notify"] != "") {
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];

View file

@ -138,6 +138,8 @@ function dfrn_request_post(&$a) {
$dfrn_request = $parms['dfrn-request'];
$photo = $parms["photo"];
/********* Escape the entire array ********/
dbesc_array($parms);
@ -185,6 +187,9 @@ function dfrn_request_post(&$a) {
if(intval($def_gid))
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
if (isset($photo))
update_contact_avatar($photo, local_user(), $r[0]["id"], true);
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
} else
$forwardurl = $a->get_baseurl()."/contacts";
@ -530,7 +535,7 @@ function dfrn_request_post(&$a) {
$parms['url'] = $url;
$parms['issued-id'] = $issued_id;
$photo = $parms["photo"];
dbesc_array($parms);
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
@ -539,7 +544,7 @@ function dfrn_request_post(&$a) {
intval($uid),
dbesc(datetime_convert()),
$parms['url'],
dbesc(normalise_link($parms['url'])),
dbesc(normalise_link($url)),
$parms['addr'],
$parms['fn'],
$parms['nick'],
@ -562,8 +567,10 @@ function dfrn_request_post(&$a) {
$parms['url'],
$parms['issued-id']
);
if(count($r))
if(count($r)) {
$contact_record = $r[0];
update_contact_avatar($photo, $uid, $contact_record["id"], true);
}
}
}

View file

@ -138,6 +138,8 @@ function notifications_content(&$a) {
$a->set_pager_itemspage(20);
}
/// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
$r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`,
`gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,
`gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,

View file

@ -191,8 +191,8 @@ function ping_init(&$a) {
function xmlize($n){
$contact = get_contact_details_by_url($n['url']);
if (isset($contact["thumb"]))
$n['photo'] = proxy_url($contact["thumb"], false, PROXY_SIZE_MICRO);
if (isset($contact["micro"]))
$n['photo'] = proxy_url($contact["micro"], false, PROXY_SIZE_MICRO);
else
$n['photo'] = proxy_url($n['photo'], false, PROXY_SIZE_MICRO);