]> git.mxchange.org Git - friendica.git/commitdiff
Imrpoved avatar handling when storing them/partly use of "micro"
authorMichael Vogel <icarus@dabo.de>
Sat, 25 Jun 2016 11:56:55 +0000 (13:56 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 25 Jun 2016 11:56:55 +0000 (13:56 +0200)
include/Contact.php
include/bbcode.php
include/diaspora.php
include/items.php
include/notifier.php
mod/dfrn_request.php
mod/notifications.php
mod/ping.php

index 3ee491e50538cd26d2347f294a223c9272399bf9..10005d3e3caad6cd4c662601a8dc044f057980c3 100644 (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"]);
index 359a7ba2f0333e4f34dcb7ede125a7288e049986..46e34a1fd505467dcd2021a39489751978e0f8f3 100644 (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]);
 
index 84aed81471f1b63a2b56e38fbc54d7bacc65c9cf..a82346db67fe1ee80df915bb3e254fd9198172b4 100644 (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
index f5e568306e4765c8a5a467a5ee5d8c7859f68d2b..1d2a775c49d27c822ef474bec1fa0093ea808393 100644 (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);
                }
 
 
index 6c90629bd87128865e0535d80e1a0523ae1f7ce7..7019ffccefa1d637130e8bd756e82ce3fcfa92cf 100644 (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"];
index 32e835b71557450863c161e5eed197dd02e09bb9..2a9f68eabd7f8e82ed24903295475d03df925c1c 100644 (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);
+                                       }
                                }
 
                        }
index f6c4e8f51fb128d7f3c719214e41a5d28d0eb58d..e0f07118f733d7f75178be66f0b0c00ca29a04a3 100644 (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`,
index c12da56131f81ae1e5ff8d4e6ae8f65403bfa67c..0ed2c31c35d014c224972abf54d4b9f61d0be5d5 100644 (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);