version v0.6.7 with moderation
This commit is contained in:
parent
5f8edccdfe
commit
48a70b8395
46 changed files with 2106 additions and 1026 deletions
|
@ -59,7 +59,7 @@ function friendicaPostRequest(login,api,data,method,rootwindow,callback) {
|
|||
//print(api+JSON.stringify(login)+Qt.atob(login.password));
|
||||
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
try{ if (xhrequest.responseText!=""){print (xhrequest.responseText)
|
||||
try{ if (xhrequest.responseText!=""){//print (xhrequest.responseText)
|
||||
callback(xhrequest.responseText)
|
||||
}else{//print("API:\n" +api+" NO RESPONSE");
|
||||
//showMessage("Error","API:\n" +api+" NO RESPONSE",rootwindow)
|
||||
|
@ -68,7 +68,8 @@ function friendicaPostRequest(login,api,data,method,rootwindow,callback) {
|
|||
}
|
||||
catch (e){
|
||||
print("API:\n" + api+" "+e+"\n Return:"+xhrequest.responseText);
|
||||
showMessage("Error", "API:\n" + api+" "+e+"\n Return:"+xhrequest.responseText,rootwindow)}
|
||||
//showMessage("Error", "API:\n" + api+" "+e+"\n Return:"+xhrequest.responseText,rootwindow)
|
||||
}
|
||||
}
|
||||
}
|
||||
xhrequest.open(method, login.server+api,true,login.username,Qt.atob(login.password));
|
||||
|
@ -199,7 +200,7 @@ function updateData(database,table, username, key, value, callback,filter,filter
|
|||
function showMessage(header,message,rootwindow){//print(message);
|
||||
var cleanmessage=message.replace(/"/g,"-");
|
||||
if(cleanmessage.length>200){cleanmessage=cleanmessage.slice(0,200)+'...'}
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+cleanmessage+'"}';
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Controls 2.15; import QtQuick.Controls.Material 2.12; Dialog{ visible: true; title:"'+header+'";standardButtons: Dialog.Ok;anchors.centerIn: parent;Label{text:" '+cleanmessage+'"}}';
|
||||
var messageObject=Qt.createQmlObject(messageString,rootwindow,"messageOutput");
|
||||
}
|
||||
|
||||
|
|
|
@ -52,16 +52,15 @@ function requestList(login,database,onlynew,rootwindow,callback) {
|
|||
|
||||
function dataRequest(login,photo,database,xhr,rootwindow) {
|
||||
// check if image exist and call download function
|
||||
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photo.id, rootwindow, function (image){
|
||||
if(image=="" || typeof(image)=="undefined"){currentimageno=currentimageno+1}else{
|
||||
|
||||
try{
|
||||
try{print("image "+ image)
|
||||
var obj = JSON.parse(image);
|
||||
if (obj.hasOwnProperty('status')){
|
||||
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (photo.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
if (photo.type=="image/jpeg" || photo.type=="image/jpg"){filesuffix=".jpg"}
|
||||
else if (photo.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
|
@ -86,7 +85,7 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
}else{
|
||||
var helpfilename=obj.filename.substring(0,obj.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (obj.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
if (obj.type=="image/jpeg" || photo.type=="image/jpg"){filesuffix=".jpg"}
|
||||
else if (obj.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
|
@ -112,7 +111,7 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
}} catch (e){
|
||||
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (photo.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
if (photo.type=="image/jpeg" || photo.type=="image/jpg"){filesuffix=".jpg"}
|
||||
else if (photo.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
|
|
|
@ -111,6 +111,21 @@ function listFriends(login,database,callback,filter,isFriend=0){
|
|||
callback(contactlist)
|
||||
});
|
||||
}
|
||||
function listBlocked(login,database,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND statusnet_blocking=1 ORDER BY screen_name');
|
||||
// check for friends
|
||||
var contactlist=[];
|
||||
for (var i=0;i<result.rows.length;i++){
|
||||
var contact=result.rows.item(i)
|
||||
contact.name=Qt.atob(contact.name);
|
||||
if (contact.screen_name==null){contact.screen_name=""}
|
||||
contactlist.push(contact)
|
||||
}
|
||||
callback(contactlist)
|
||||
});
|
||||
}
|
||||
|
||||
function listHashtags(login,database,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -574,6 +589,7 @@ function cleanhelpernews(database,user,helpernews,allcontacts){
|
|||
helpernews.statusnet_html=Qt.atob(helpernews.statusnet_html);
|
||||
helpernews.text=Qt.atob(helpernews.text);
|
||||
helpernews.id=helpernews.status_id;
|
||||
try{let geoobj=JSON.parse(helpernews.geo); helpernews.external_url=geoobj.external_url}catch(e){}
|
||||
helpernews.friendica_author=objFromArray(allcontacts,"url",helpernews.friendica_owner);
|
||||
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))};
|
||||
return helpernews
|
||||
|
|
|
@ -127,9 +127,15 @@ WorkerScript.onMessage = function(msg) {
|
|||
var newsitemobject=msg.news[j];
|
||||
newsitemobject=beautify(newsitemobject,msg);
|
||||
if (!(typeof(newsitemobject.currentconversation)=='undefined') && (newsitemobject.currentconversation.length>0)){
|
||||
newsitemobject.lastcomment=beautify(newsitemobject.currentconversation[newsitemobject.currentconversation.length-1],msg);
|
||||
newsitemobject.lastcomment.indent=1
|
||||
newsitemobject.lastcomment.isLastComment=true
|
||||
let n=1;
|
||||
while ((n<newsitemobject.currentconversation.length)&&(newsitemobject.currentconversation[newsitemobject.currentconversation.length-n].user.statusnet_blocking==true)) {
|
||||
n++;
|
||||
}
|
||||
if (n<newsitemobject.currentconversation.length){
|
||||
newsitemobject.lastcomment=beautify(newsitemobject.currentconversation[newsitemobject.currentconversation.length-n],msg);
|
||||
newsitemobject.lastcomment.indent=1
|
||||
newsitemobject.lastcomment.isLastComment=true
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.method=="conversation"){
|
||||
|
@ -137,12 +143,10 @@ WorkerScript.onMessage = function(msg) {
|
|||
var count=0;
|
||||
var firstReply=0;
|
||||
for (var k=msg.model.count-1;k>-1;k--){
|
||||
//print("newsitemobject.in_reply_to_status_id "+newsitemobject.in_reply_to_status_id+" msg.model.get(k).newsitemobject.in_reply_to_status_id "+msg.model.get(k).newsitemobject.in_reply_to_status_id)
|
||||
if (newsitemobject.in_reply_to_status_id==msg.model.get(k).newsitemobject.id){
|
||||
if (newsitemobject.in_reply_to_status_id==msg.model.get(k).newsitemobject.id){
|
||||
newsitemobject.indent=(msg.model.get(k).newsitemobject.indent||0)+1;
|
||||
if (newsitemobject.indent>6){newsitemobject.indent=6};
|
||||
firstReply=k;
|
||||
//break;
|
||||
}
|
||||
if (newsitemobject.in_reply_to_status_id==msg.model.get(k).newsitemobject.in_reply_to_status_id){
|
||||
count+=1
|
||||
|
@ -151,11 +155,10 @@ WorkerScript.onMessage = function(msg) {
|
|||
}}
|
||||
data=({"newsitemobject": newsitemobject})
|
||||
}
|
||||
|
||||
if(data.newsitemobject.user.statusnet_blocking==true){break}
|
||||
if(msg.method=="append") {
|
||||
msg.model.insert(j, data)
|
||||
} else if (msg.method=="conversation" && firstReply>0){
|
||||
//print("j "+j +" firstReply "+firstReply+" count "+count)
|
||||
msg.model.insert(firstReply+count+1, data)
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -408,7 +408,7 @@ function cleanContacts(login,database,callback){
|
|||
db.transaction( function(tx) {
|
||||
var oldestnewsrs= tx.executeSql('SELECT created_at FROM news WHERE username="'+login.username+'" AND messagetype=0 ORDER BY created_at ASC LIMIT 1');
|
||||
if (oldestnewsrs.rows.length>0){ var oldestnewsTime=oldestnewsrs.rows.item(0).created_at- 604800000;} else{var oldestnewsTime=0} //contacts can be 7 days old
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend=0 AND imageAge<'+oldestnewsTime); // check for friends
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend=0 AND statusnet_blocking<>1 AND imageAge<'+oldestnewsTime); // check for friends
|
||||
for (var i=0;i<result.rows.length;i++){
|
||||
filesystem.rmFile(result.rows.item(i).profile_image);
|
||||
var deleters = tx.executeSql('DELETE from contacts WHERE username="'+login.username+'" AND url="'+result.rows.item(i).url+'"');
|
||||
|
@ -455,7 +455,7 @@ function processNews(api,data){//print("processnews "+ " api "+ api + " data "+d
|
|||
usermessages.push(newslist.status);
|
||||
newslist=usermessages;
|
||||
}
|
||||
if (data=="" || api=="/api/v1/statuses"){print("data "+data); newsBusy.running=false}
|
||||
if (data=="" || api=="/api/v1/statuses"){newsBusy.running=false}
|
||||
else if (typeof(newslist)=='undefined'){
|
||||
Helperjs.showMessage(qsTr("Undefined Array Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
|
||||
}
|
||||
|
@ -518,6 +518,10 @@ function processNews(api,data){//print("processnews "+ " api "+ api + " data "+d
|
|||
if (api=="/api/statuses/replies"){newslist[n].messagetype=3}else{newslist[n].messagetype=0;}
|
||||
newslist[n].friendica_author=cleanUser(newslist[n].friendica_author);
|
||||
newslist[n].user=cleanUser(newslist[n].user);
|
||||
try{
|
||||
let localContact=Newsjs.objFromArray(allcontacts,"id",newslist[n].user.id);
|
||||
newslist[n].user.statusnet_blocking=localContact.statusnet_blocking
|
||||
}catch(e){}
|
||||
//if (newslist[n].friendica_title!="") {newslist[n].statusnet_html="<b>"+newslist[n].friendica_title +"</b><br><br>"+newslist[n].friendica_html;}
|
||||
//else{ //friendica_title also included in html
|
||||
newslist[n].statusnet_html=newslist[n].friendica_html
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue