diff --git a/QvitterPlugin.php b/QvitterPlugin.php index 6f7cf8a..689ce3e 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -197,6 +197,12 @@ class QvitterPlugin extends Plugin { array('notice' => '[0-9]+'), 'qvitter'); } + + // if qvitter is opt-out, disable the default register page + if(self::settings('enabledbydefault')) { + $m->connect('main/register', + array('action' => 'qvitter')); + } } diff --git a/actions/apiqvitternotifications.php b/actions/apiqvitternotifications.php index 05f700b..bf1aa8c 100644 --- a/actions/apiqvitternotifications.php +++ b/actions/apiqvitternotifications.php @@ -91,9 +91,17 @@ class ApiQvitterNotificationsAction extends ApiPrivateAuthAction foreach($this->notifications as $notification) { + // all but follow has an notice if($notification->ntype != 'follow') { - $notice = self::twitterSimpleStatusArray(Notice::getKV($notification->notice_id)); + + // we need a notice id here, skip this notification if notice id is null + if($notification->notice_id === null) { + continue; + } + else { + $notice = self::twitterSimpleStatusArray(Notice::getKV($notification->notice_id)); + } } $notifications_populated[] = array( diff --git a/actions/qvitter.php b/actions/qvitter.php index a8bfe64..d9e659a 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -386,11 +386,11 @@ class QvitterAction extends ApiAction - - - + + + - + diff --git a/edited-gnu-social-files/lib/apiauthaction.php b/edited-gnu-social-files/lib/apiauthaction.php index 672e35b..af50db4 100644 --- a/edited-gnu-social-files/lib/apiauthaction.php +++ b/edited-gnu-social-files/lib/apiauthaction.php @@ -87,7 +87,8 @@ class ApiAuthAction extends ApiAction // qvitterfix, accepts regular login session - if ($this->scoped) { + if (common_logged_in()) { + $this->scoped = Profile::current(); $this->auth_user = $this->scoped->getUser(); $this->access = self::READ_WRITE; } @@ -290,7 +291,7 @@ class ApiAuthAction extends ApiAction // show error if the user clicks 'cancel' // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel". - $this->clientError(_('Could not authenticate you.'), 401); + $this->clientError(_('Could not authenticate you.'), 400); } elseif($required) { @@ -319,7 +320,7 @@ class ApiAuthAction extends ApiAction ); $this->logAuthFailure($msg); // TRANS: Client error thrown when authentication fails. - $this->clientError(_('Could not authenticate you.'), 401); + $this->clientError(_('Could not authenticate you.'), 400); } } else { diff --git a/js/ajax-functions.js b/js/ajax-functions.js index eb59a51..30dcee9 100644 --- a/js/ajax-functions.js +++ b/js/ajax-functions.js @@ -92,6 +92,14 @@ function getFromAPI(stream, actionOnSuccess) { $.ajax({ url: window.apiRoot + stream + qOrAmp(stream) + 't=' + timeNow(), type: "GET", dataType: 'json', + statusCode: { + 400:function() { + location.reload(); // we may have been logged out in another tab, reload page + }, + 404:function() { + window.location.replace(window.siteInstanceURL); // redirect to frontpage, probably when trying to access non-existing users + } + }, success: function(data) { data = convertEmptyObjectToEmptyArray(data); diff --git a/js/dom-functions.js b/js/dom-functions.js index ca62d34..f4eaa62 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -842,7 +842,9 @@ function expand_queet(q,doScrolling) { if(q.hasClass('expanded') && !q.hasClass('collapsing')) { var sel = getSelection().toString(); - if(!sel && !q.find('.queet-button').children('button').hasClass('enabled')) { // don't collapse if text is selected, or if queet has an active queet button + if(!sel + && !q.find('.queet-button').children('button').hasClass('enabled') + && !q.find('.queet-button').children('button').hasClass('too-long')) { // don't collapse if text is selected, or if queet has an active queet button, or if queet text is too long // remove some things right away q.find('.inline-reply-caret').remove(); @@ -1403,7 +1405,7 @@ function checkForHiddenConversationQueets(qid) { · · · · · · · · · · · · · · */ -function addToFeed(feed, after, extraClasses) { +function addToFeed(feed, after, extraClasses, isReply) { // some streams, e.g. /statuses/show/1234.json is not enclosed in an array, make sure it is if(!$.isArray(feed)) { @@ -1414,8 +1416,9 @@ function addToFeed(feed, after, extraClasses) { var extraClassesThisRun = extraClasses; - // if this is the notifications feed - if(window.currentStream.substring(0,35) == 'qvitter/statuses/notifications.json') { + // if this is the notifications feed, but not if it is a reply + if(window.currentStream.substring(0,35) == 'qvitter/statuses/notifications.json' + && !isReply) { // only if this notification isn't already in stream @@ -1431,12 +1434,12 @@ function addToFeed(feed, after, extraClasses) { if(obj.ntype == 'like') { var noticeTime = parseTwitterDate(obj.notice.created_at); obj.notice = convertNewGNUSocialURItoURL(obj.notice); - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xFavedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xFavedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; } else if(obj.ntype == 'repeat') { obj.notice = convertNewGNUSocialURItoURL(obj.notice); var noticeTime = parseTwitterDate(obj.notice.created_at); - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xRepeatedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xRepeatedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; } else if(obj.ntype == 'mention') { var notificationHtml = buildQueetHtml(obj.notice, obj.id, extraClassesThisRun + ' notification mention'); @@ -1445,7 +1448,7 @@ function addToFeed(feed, after, extraClasses) { var notificationHtml = buildQueetHtml(obj.notice, obj.id, extraClassesThisRun + ' notification reply'); } else if(obj.ntype == 'follow') { - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xStartedFollowingYou + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xStartedFollowingYou + '
'; } if(after) { diff --git a/js/misc-functions.js b/js/misc-functions.js index 176208a..be6968b 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -514,8 +514,8 @@ function qOrAmp(stream) { function countCharsInQueetBox(src,trgt,btn) { - var $src_txt = $('
').append($.trim(src.html()).replace(/ /gi,' ').replace(/
/i,'').replace(/
/gi,"x")); - var numchars = ($.trim($src_txt.text())).length; + var $src_txt = $('
').append($.trim(src.text().replace(/^\s+|\s+$/g, ''))); + var numchars = ($src_txt.text()).length; // check for long urls and disable/enable url shorten button if present var longurls = 0; @@ -535,6 +535,7 @@ function countCharsInQueetBox(src,trgt,btn) { if(numchars > 0 && numchars < window.textLimit+1) { btn.removeClass('disabled'); btn.addClass('enabled'); + btn.removeClass('too-long'); // deactivate button if it's equal to the start text var queetBox = btn.closest('.inline-reply-queetbox').children('.queet-box-syntax'); @@ -546,9 +547,15 @@ function countCharsInQueetBox(src,trgt,btn) { } } } + else if(numchars > window.textLimit){ + btn.removeClass('enabled'); + btn.addClass('disabled'); + btn.addClass('too-long'); + } else { btn.removeClass('enabled'); btn.addClass('disabled'); + btn.removeClass('too-long'); } diff --git a/js/qvitter.js b/js/qvitter.js index d62d92f..2583a67 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -1376,7 +1376,7 @@ $('body').on('click', '.queet-toolbar button',function () { var queetBox = $(this).parent().parent().siblings('.queet-box'); var queetBoxID = queetBox.attr('id'); - var queetText = $.trim(queetBox.html().replace(/\n/g,'').replace(/
/g,"\n")); + var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '')); var queetHtml = '
'; queetHtml = detectRTL(queetHtml); @@ -1420,7 +1420,7 @@ $('body').on('click', '.queet-toolbar button',function () { // show real queet var new_queet = Array(); new_queet[0] = data; - addToFeed(new_queet,tempPostId,'visible'); + addToFeed(new_queet,tempPostId,'visible', true); // remove temp queet $('#' + tempPostId).remove();