small fixes
This commit is contained in:
parent
f3161ec32f
commit
cff9c53f78
|
@ -334,14 +334,7 @@ class QvitterPlugin extends Plugin {
|
|||
}
|
||||
|
||||
if($user instanceof User) {
|
||||
if (common_logged_in()) {
|
||||
$profilecurrent = Profile::current();
|
||||
$currentuser = $profilecurrent->getUser();
|
||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($user->getProfile(),$currentuser)));
|
||||
}
|
||||
else {
|
||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($user->getProfile())));
|
||||
}
|
||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($user->getProfile())));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1096,7 +1089,7 @@ class QvitterPlugin extends Plugin {
|
|||
}
|
||||
|
||||
|
||||
function qvitterTwitterUserArray($profile, $logged_in=false)
|
||||
function qvitterTwitterUserArray($profile)
|
||||
{
|
||||
$twitter_user = array();
|
||||
|
||||
|
@ -1159,14 +1152,14 @@ class QvitterPlugin extends Plugin {
|
|||
$twitter_user['following'] = false;
|
||||
$twitter_user['statusnet_blocking'] = false;
|
||||
|
||||
$logged_in_profile = Profile::current();
|
||||
$logged_in_profile = false;
|
||||
|
||||
if ($logged_in) {
|
||||
if(common_logged_in()) {
|
||||
|
||||
$twitter_user['following'] = $logged_in->isSubscribed($profile);
|
||||
$twitter_user['statusnet_blocking'] = $logged_in->hasBlocked($profile);
|
||||
$logged_in_profile = Profile::current();
|
||||
|
||||
$logged_in_profile = $logged_in->getProfile();
|
||||
$twitter_user['following'] = $logged_in_profile->isSubscribed($profile);
|
||||
$twitter_user['statusnet_blocking'] = $logged_in_profile->hasBlocked($profile);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -49,51 +49,51 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
|||
$profileurl = urldecode($this->arg('profileurl'));
|
||||
$nickname = urldecode($this->arg('nickname'));
|
||||
|
||||
$this->profile = new stdClass();
|
||||
$this->profile = new stdClass();
|
||||
$this->profile->external = null;
|
||||
$this->profile->local = null;
|
||||
|
||||
$this->profile->local = null;
|
||||
|
||||
// we can get urls of two types of urls (1) ://instance/nickname
|
||||
// (2) ://instance/user/1234
|
||||
// (2) ://instance/user/1234
|
||||
//
|
||||
// in case (1) we have the problem that the html can be outdated,
|
||||
// i.e. the user can have changed her nickname. we also have no idea
|
||||
// if it is a multi or single user instance, which forces us to
|
||||
// guess the api root url.
|
||||
// if it is a multi or single user instance, which forces us to
|
||||
// guess the api root url.
|
||||
//
|
||||
// in case (2) we have another problem: we can't use that url to find
|
||||
// in case (2) we have another problem: we can't use that url to find
|
||||
// the local profile for the external user, we need url:s of type (2)
|
||||
// for that. so we have to try getting the nickname from the external
|
||||
// instance first
|
||||
|
||||
|
||||
// case (2)
|
||||
// case (2)
|
||||
if(strstr($profileurl, '/user/')) {
|
||||
|
||||
$external_user_id = substr($profileurl,strpos($profileurl,'/user/')+6);
|
||||
$external_instance_url = substr($profileurl,0,strpos($profileurl,'/user/')+1);
|
||||
|
||||
if(!is_numeric($external_user_id)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
$external_profile = $this->getProfileFromExternalInstance($external_instance_url,$external_user_id);
|
||||
|
||||
if(!isset($external_profile->statusnet_profile_url)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->profile->external = $external_profile;
|
||||
$this->profile->external = $external_profile;
|
||||
$local_profile = Profile::getKV('profileurl',$external_profile->statusnet_profile_url);
|
||||
|
||||
if(!$local_profile instanceof Profile) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->profile->local = $this->twitterUserArray($local_profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// case (1)
|
||||
$local_profile = Profile::getKV('profileurl',$profileurl);
|
||||
|
||||
|
@ -104,21 +104,21 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
|||
$external_instance_url = $local_profile->profileurl;
|
||||
}
|
||||
// multi user instance
|
||||
else {
|
||||
$external_instance_url = substr($local_profile->profileurl, 0, strrpos($local_profile->profileurl, '/'));
|
||||
}
|
||||
else {
|
||||
$external_instance_url = substr($local_profile->profileurl, 0, strrpos($local_profile->profileurl, '/'));
|
||||
}
|
||||
|
||||
$external_profile = $this->getProfileFromExternalInstance($external_instance_url,$local_profile->nickname);
|
||||
|
||||
if(!isset($external_profile->statusnet_profile_url)) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->profile->external = $external_profile;
|
||||
$this->profile->local = $this->twitterUserArray($local_profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if we don't know about this user, or the user has changed nickname
|
||||
// if profile url ends with '/' this is probably an unknown single user instance
|
||||
if(substr($profileurl, -1)==='/') {
|
||||
|
@ -128,17 +128,17 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
|||
|
||||
// multi user instance
|
||||
else {
|
||||
$user_id_or_nickname = substr($profileurl, strrpos($profileurl, '/')+1);
|
||||
$instanceurl = substr($profileurl, 0, strrpos($profileurl, '/'));
|
||||
}
|
||||
$user_id_or_nickname = substr($profileurl, strrpos($profileurl, '/')+1);
|
||||
$instanceurl = substr($profileurl, 0, strrpos($profileurl, '/'));
|
||||
}
|
||||
$external_profile = $this->getProfileFromExternalInstance($instanceurl,$user_id_or_nickname);
|
||||
if(!isset($external_profile->statusnet_profile_url)) {
|
||||
return true;
|
||||
}
|
||||
$this->profile->external = $external_profile;
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
$this->profile->external = $external_profile;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,21 +172,21 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get profile from external instance
|
||||
*
|
||||
* @return null or profile object
|
||||
*/
|
||||
function getProfileFromExternalInstance($instance_url,$user_id_or_nickname)
|
||||
function getProfileFromExternalInstance($instance_url,$user_id_or_nickname)
|
||||
{
|
||||
$apicall = $instance_url.'/api/users/show.json?id='.$user_id_or_nickname;
|
||||
$apicall = $instance_url.'/api/users/show.json?id='.$user_id_or_nickname;
|
||||
$client = new HTTPClient();
|
||||
$response = $client->get($apicall);
|
||||
// json_decode returns null if it fails to decode
|
||||
return $response->isOk() ? json_decode($response->getBody()) : null;
|
||||
return $response->isOk() ? json_decode($response->getBody()) : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
|
|||
// blur any selected links
|
||||
$('a').blur();
|
||||
|
||||
// null any searches
|
||||
// null any pagings
|
||||
$('#feed-body').removeAttr('data-search-page-number');
|
||||
|
||||
// remember the most recent stream
|
||||
|
@ -844,6 +844,7 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
|
|||
$('#feed').animate({opacity:'1'},150); // fade in
|
||||
$('.reload-stream').show();
|
||||
$('#feed-body').removeAttr('data-end-reached');
|
||||
$('#feed-body').removeAttr('data-search-page-number');
|
||||
$('body').removeClass('loading-older');$('body').removeClass('loading-newer');
|
||||
$('html,body').scrollTop(0); // scroll to top
|
||||
|
||||
|
@ -1652,7 +1653,13 @@ function addToFeed(feed, after, extraClasses, isReply) {
|
|||
if(typeof window.loggedIn.screen_name != 'undefined' // if logged in
|
||||
&& window.loggedIn.id != obj.id) { // not if this is me
|
||||
if(!(obj.statusnet_profile_url.indexOf('/twitter.com/')>-1 && obj.following === false)) { // only unfollow twitter users
|
||||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + obj.id + '" data-follow-user="' + obj.statusnet_profile_url + '" type="button" class="qvitter-follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
var followButton = '<div class="user-actions">\
|
||||
<button data-follow-user-id="' + obj.id + '" data-follow-user="' + obj.statusnet_profile_url + '" type="button" class="qvitter-follow-button ' + followingClass + '">\
|
||||
<span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span>\
|
||||
<span class="button-text following-text">' + window.sL.userFollowing + '</span>\
|
||||
<span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span>\
|
||||
</button>\
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -645,17 +645,19 @@ function displayOrHideUnreadNotifications(notifications) {
|
|||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
function markAllNotificationsAsSeen() {
|
||||
function markAllNotificationsAsSeen(arg,callback) {
|
||||
display_spinner();
|
||||
getFromAPI('qvitter/mark_all_notifications_as_seen.json',function(data){
|
||||
if(data === false) {
|
||||
showErrorMessage(window.sL.ERRORfailedMarkingAllNotificationsAsRead);
|
||||
callback(true);
|
||||
}
|
||||
else {
|
||||
helloAPI(function(){
|
||||
$('.not-seen-disc').remove();
|
||||
$('#new-queets-bar').trigger('click'); // show any hidden notifications (this will also remove the dropdown menu)
|
||||
remove_spinner();
|
||||
callback(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1150,6 +1150,16 @@ $('body').on('click',function(e){
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
$('body').on('click','.row-type-function',function(e){
|
||||
|
||||
var thisFunctionRow = $(this);
|
||||
|
||||
// don't invoke the function again if it's not finished last time
|
||||
if(thisFunctionRow.hasClass('clicked')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
thisFunctionRow.addClass('clicked');
|
||||
|
||||
var functionName = $(this).attr('data-function-name');
|
||||
if($(this).attr('data-function-arguments') == 'undefined') {
|
||||
var functionArguments = false;
|
||||
|
@ -1157,7 +1167,11 @@ $('body').on('click','.row-type-function',function(e){
|
|||
else {
|
||||
var functionArguments = JSON.parse($(this).attr('data-function-arguments'));
|
||||
}
|
||||
window[functionName](functionArguments);
|
||||
window[functionName](functionArguments, function(success){
|
||||
if(success) {
|
||||
thisFunctionRow.removeClass('clicked');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user