]> git.mxchange.org Git - friendica.git/commitdiff
API: Improvements for fetching the nick name
authorMichael Vogel <icarus@dabo.de>
Mon, 23 Nov 2015 17:42:45 +0000 (18:42 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 23 Nov 2015 17:42:45 +0000 (18:42 +0100)
include/api.php

index 873006ac243709724e03b69d9de877898c0b320e..caa43649efca4fc2ab00331bc3e4fd9fc6b9704e 100644 (file)
@@ -2849,15 +2849,29 @@ function api_share_as_retweet(&$item) {
 
 function api_get_nick($profile) {
 /* To-Do:
- - remove trailing jung from profile url
+ - remove trailing junk from profile url
  - pump.io check has to check the website
 */
 
        $nick = "";
 
-       $friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2", $profile);
-       if ($friendica != $profile)
-               $nick = $friendica;
+       $r = q("SELECT `nick` FROM `gcontact` WHERE `nurl` = '%s'",
+               dbesc(normalise_link($profile)));
+       if ($r)
+               $nick = $r[0]["nick"];
+
+       if (!$nick == "") {
+               $r = q("SELECT `nick` FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s'",
+                       dbesc(normalise_link($profile)));
+               if ($r)
+                       $nick = $r[0]["nick"];
+       }
+
+       if (!$nick == "") {
+               $friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2", $profile);
+               if ($friendica != $profile)
+                       $nick = $friendica;
+       }
 
        if (!$nick == "") {
                $diaspora = preg_replace("=https?://(.*)/u/(.*)=ism", "$2", $profile);