mastodon fixes for last commit

This commit is contained in:
Hannes Mannerheim 2017-04-06 14:22:54 +02:00
parent a37a4cb9f9
commit 3968aba9c3
3 changed files with 18 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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(){