Merge branch 'master_fix_remoteProfilStaticAvatar' into 'master'

FixLocal profil are not detected with static avatar server

See merge request !90
This commit is contained in:
hannes 2017-05-29 09:46:22 +00:00
commit 35b3e67480
2 changed files with 31 additions and 27 deletions

View File

@ -98,17 +98,27 @@ class QvitterAction extends ApiAction
$siterootdomain = common_config('site','server'); $siterootdomain = common_config('site','server');
$qvitterpath = Plugin::staticPath('Qvitter', ''); $qvitterpath = Plugin::staticPath('Qvitter', '');
$apiroot = common_path('api/', StatusNet::isHTTPS()); $apiroot = common_path('api/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS());
$favicon_path = QvitterPlugin::settings("favicon_path");
$attachmentconfig=common_config('attachments'); $attachmentconfig=common_config('attachments');
if(StatusNet::isHTTPS() && $attachmentconfig['sslserver']){ if(StatusNet::isHTTPS() && $attachmentconfig['sslserver']){
$attachmentroot ='https://'.$attachmentconfig['sslserver'].$attachmentconfig['path']; $attachmentroot ='https://'.$attachmentconfig['sslserver'].$attachmentconfig['path'];
} elseif(!StatusNet::isHTTPS() && $attachmentconfig['server']) { } elseif(!StatusNet::isHTTPS() && $attachmentconfig['server']) {
$attachmentroot ='http://'.$attachmentconfig['server'].$attachmentconfig['path']; $attachmentroot ='http://'.$attachmentconfig['server'].$attachmentconfig['path'];
} else { } else {
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS()); $attachmentroot = $instanceurl.$attachmentconfig['path'];
} }
$instanceurl = common_path('', StatusNet::isHTTPS()); $avatarconfig=common_config('avatar');
$favicon_path = QvitterPlugin::settings("favicon_path"); if($avatarconfig['server']) {
if(StatusNet::isHTTPS() ){
$avatarroot ='https://'.$avatarconfig['server'].$avatarconfig['path'];
} else {
$avatarroot ='http://'.$avatarconfig['server'].$avatarconfig['path'];
}
} else {
$avatarroot = $instanceurl.$avatarconfig['path'];
}
// user's browser's language setting // user's browser's language setting
$user_browser_language = 'en'; // use english if we can't find the browser language $user_browser_language = 'en'; // use english if we can't find the browser language
@ -302,10 +312,8 @@ class QvitterAction extends ApiAction
} }
} }
?> ?>
<script> <script>
/* /*
@licstart The following is the entire license notice for the @licstart The following is the entire license notice for the
JavaScript code in this page. JavaScript code in this page.
@ -373,6 +381,7 @@ class QvitterAction extends ApiAction
window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?>'; window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?>';
window.siteRootDomain = '<?php print $siterootdomain; ?>'; window.siteRootDomain = '<?php print $siterootdomain; ?>';
window.siteInstanceURL = '<?php print $instanceurl; ?>'; window.siteInstanceURL = '<?php print $instanceurl; ?>';
window.avatarServer= <?php print json_encode(common_config('avatar', 'server')) ?>;
window.defaultLinkColor = '<?php print QvitterPlugin::settings("defaultlinkcolor"); ?>'; window.defaultLinkColor = '<?php print QvitterPlugin::settings("defaultlinkcolor"); ?>';
window.defaultBackgroundColor = '<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?>'; window.defaultBackgroundColor = '<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?>';
window.siteBackground = '<?php print QvitterPlugin::settings("sitebackground"); ?>'; window.siteBackground = '<?php print QvitterPlugin::settings("sitebackground"); ?>';
@ -384,6 +393,7 @@ class QvitterAction extends ApiAction
window.commonSessionToken = '<?php print common_session_token(); ?>'; window.commonSessionToken = '<?php print common_session_token(); ?>';
window.siteMaxThumbnailSize = <?php print common_config('thumbnail', 'maxsize'); ?>; window.siteMaxThumbnailSize = <?php print common_config('thumbnail', 'maxsize'); ?>;
window.siteAttachmentURLBase = '<?php print $attachmentroot; ?>'; window.siteAttachmentURLBase = '<?php print $attachmentroot; ?>';
window.siteAvatarURLBase = '<?php print $avatarroot; ?>';
window.siteEmail = '<?php print common_config('site', 'email'); ?>'; window.siteEmail = '<?php print common_config('site', 'email'); ?>';
window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?>'; window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?>';
window.siteLicenseURL = '<?php print common_config('license', 'url'); ?>'; window.siteLicenseURL = '<?php print common_config('license', 'url'); ?>';

View File

@ -726,18 +726,14 @@ function updateAllQueetsTimes() {
· · · · · · · · · */ · · · · · · · · · */
function isLocalURL(url) { function isLocalURL(url) {
if(url.substring(0,window.siteInstanceURL.length) == window.siteInstanceURL) { if(url.substring(0,window.siteInstanceURL.length) == window.siteInstanceURL // site url
|| url.substring(0,window.siteAttachmentURLBase.length) == window.siteAttachmentURLBase // attachment url
|| url.substring(0,window.siteAvatarURLBase.length) == window.siteAvatarURLBase // avatar url
) {
return true; return true;
} }
else {
if(url.substring(0,window.siteAttachmentURLBase.length) == window.siteAttachmentURLBase) {
return true;
}
else {
return false; return false;
} }
}
}
/* · /* ·
@ -1052,12 +1048,10 @@ function userArrayCacheGetUserNicknameById(id) {
· · · · · · · · · */ · · · · · · · · · */
function detectLocalOrExternalUserObject(userObject) { function detectLocalOrExternalUserObject(userObject) {
var dataProfileImageUrlWithoutProtocol = removeProtocolFromUrl(userObject.profile_image_url);
var siteInstanceURLWithoutProtocol = removeProtocolFromUrl(window.siteInstanceURL); if(isLocalURL(userObject.profile_image_url) ) {
if(dataProfileImageUrlWithoutProtocol.substring(0,siteInstanceURLWithoutProtocol.length) == siteInstanceURLWithoutProtocol){
return 'local'; return 'local';
} } else {
else {
return 'external'; return 'external';
} }
} }