From 3968aba9c3fd295da588bb28af4cc995a912aca2 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Thu, 6 Apr 2017 14:22:54 +0200 Subject: [PATCH] mastodon fixes for last commit --- actions/apiexternalusershow.php | 4 ++-- js/misc-functions.js | 5 +++++ js/qvitter.js | 13 +++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/actions/apiexternalusershow.php b/actions/apiexternalusershow.php index d39a4d3..5d5fb7b 100644 --- a/actions/apiexternalusershow.php +++ b/actions/apiexternalusershow.php @@ -54,7 +54,6 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction $this->profile = new stdClass(); $this->profile->external = null; $this->profile->local = null; - $this->profile->ostatus = null; // the user might not exist in our db yet, try to use the Ostatus plugin // to get it in there @@ -112,6 +111,8 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction if($local_profile instanceof Profile) { + $this->profile->local = $this->twitterUserArray($local_profile); + // if profile url is not ending with nickname, this is probably a single user instance if(!substr($local_profile->profileurl, -strlen($local_profile->nickname))===$local_profile->nickname) { $external_instance_url = $local_profile->profileurl; @@ -128,7 +129,6 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction } $this->profile->external = $external_profile; - $this->profile->local = $this->twitterUserArray($local_profile); return true; } diff --git a/js/misc-functions.js b/js/misc-functions.js index ba9663e..b53f9be 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -1096,6 +1096,11 @@ function guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(profileUrl, ni guessedInstanceUrl = guessedInstanceUrl.slice(0,-1); } + // fix new mastodon style profile urls + if(guessedInstanceUrl.indexOf('/@') > -1) { + guessedInstanceUrl = guessedInstanceUrl.substring(0, guessedInstanceUrl.indexOf('/@')); + } + return guessedInstanceUrl; } diff --git a/js/qvitter.js b/js/qvitter.js index 106afcd..e24eac0 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -532,6 +532,7 @@ $('#find-someone input').keyup(function(e){ var domain = val.substring(val.indexOf('@')+1); var urlToTry = 'https://' + domain + '/' + username; var secondUrlToTry = 'http://' + domain + '/' + username; + var thirdUrlToTry = 'https://' + domain + '/@' + username; // mastodon getFromAPI('qvitter/external_user_show.json?profileurl=' + encodeURIComponent(urlToTry),function(data){ if(data && data.local !== null) { @@ -547,7 +548,16 @@ $('#find-someone input').keyup(function(e){ }); } else { - cantFindSomeone(thisFindSomeoneInput); + getFromAPI('qvitter/external_user_show.json?profileurl=' + encodeURIComponent(thirdUrlToTry),function(data){ + if(data && data.local !== null) { + setNewCurrentStream(pathToStreamRouter('user/' + data.local.id),true,false,function(){ + foundSomeone(thisFindSomeoneInput); + }); + } + else { + cantFindSomeone(thisFindSomeoneInput); + } + }); } }); } @@ -559,7 +569,6 @@ $('#find-someone input').keyup(function(e){ } }); - function cantFindSomeone(thisFindSomeoneInput) { thisFindSomeoneInput.css('background-color','pink'); thisFindSomeoneInput.effect('shake',{distance:5,times:3,duration:700},function(){