disregard protocol for quoted notices

This commit is contained in:
Hannes Mannerheim 2016-01-07 16:07:15 +01:00
parent 34519017ac
commit 3c6243ac50
3 changed files with 17 additions and 4 deletions

View File

@ -578,9 +578,14 @@ class QvitterPlugin extends Plugin {
$noticeurl = common_path('notice/', StatusNet::isHTTPS()); $noticeurl = common_path('notice/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS()); $instanceurl = common_path('', StatusNet::isHTTPS());
// remove protocol for the comparison below
$noticeurl_wo_protocol = preg_replace('(^https?://)', '', $noticeurl);
$instanceurl_wo_protocol = preg_replace('(^https?://)', '', $instanceurl);
$attachment_url_wo_protocol = preg_replace('(^https?://)', '', $attachment['url']);
// local notice urls // local notice urls
if(stristr($attachment['url'], $noticeurl)) { if(strpos($attachment_url_wo_protocol, $noticeurl_wo_protocol) === 0) {
$possible_notice_id = str_replace($noticeurl,'',$attachment['url']); $possible_notice_id = str_replace($noticeurl_wo_protocol,'',$attachment_url_wo_protocol);
if(ctype_digit($possible_notice_id)) { if(ctype_digit($possible_notice_id)) {
$quoted_notice = Notice::getKV('id',$possible_notice_id);; $quoted_notice = Notice::getKV('id',$possible_notice_id);;
} }
@ -588,7 +593,8 @@ class QvitterPlugin extends Plugin {
// remote. but we don't want to lookup every url in the db, // remote. but we don't want to lookup every url in the db,
// so only do this if we have reason to believe this might // so only do this if we have reason to believe this might
// be a remote notice url // be a remote notice url
elseif(!stristr($attachment['url'], $instanceurl) && stristr($attachment['url'],'/notice/')) { // VERY INEFFICIENT!! maybe index the url column in the notice table?
elseif(strpos($attachment_url_wo_protocol, $instanceurl_wo_protocol) !== 0 && stristr($attachment_url_wo_protocol,'/notice/')) {
$quoted_notice = Notice::getKV('url',$attachment['url']); $quoted_notice = Notice::getKV('url',$attachment['url']);
} }

View File

@ -91,4 +91,4 @@ for ideas about paths for the API extensions.
Notes Notes
----- -----
Qvitter is tested with the latest GNU social nightly and also an older version: GNU social version 1.1.1-alpha2 (7e47026085fa4f2071e694d9c3e3fe2aa5142135, 24 aug 2014). Qvitter is tested with the latest GNU social nightly

View File

@ -850,6 +850,13 @@ function searchForUpdatedNoticeData(obj) {
streamItemFoundInFeed.attr('data-attachments',JSON.stringify(obj.attachments)); streamItemFoundInFeed.attr('data-attachments',JSON.stringify(obj.attachments));
var attachmentsHTMLBuild = buildAttachmentHTML(obj.attachments); var attachmentsHTMLBuild = buildAttachmentHTML(obj.attachments);
queetFoundInFeed.find('.queet-thumbs').remove(); queetFoundInFeed.find('.queet-thumbs').remove();
queetFoundInFeed.find('.quoted-notices').remove();
// we might want to hide urls (rendered as attachments) in the queet text
$.each(queetFoundInFeed.find('.queet-text').find('a'),function(){
if(attachmentsHTMLBuild.urlsToHide.indexOf($(this).text()) > -1) {
$(this).css('display','none');
}
});
queetFoundInFeed.find('.stream-item-footer').before(attachmentsHTMLBuild.html); queetFoundInFeed.find('.stream-item-footer').before(attachmentsHTMLBuild.html);
} }