bugfixes reply in Friendica 3/2022 and image download
This commit is contained in:
parent
4ffae4ac31
commit
48a904b8c0
15 changed files with 909 additions and 855 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!=""){
|
||||
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)
|
||||
|
|
|
@ -54,7 +54,8 @@ 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==""){currentimageno=currentimageno+1}else{
|
||||
if(image=="" || typeof(image)=="undefined"){currentimageno=currentimageno+1}else{
|
||||
|
||||
try{
|
||||
var obj = JSON.parse(image);
|
||||
if (obj.hasOwnProperty('status')){
|
||||
|
@ -109,6 +110,30 @@ 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"}
|
||||
else if (photo.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
photo.filename=photo["id"]+filesuffix;
|
||||
}
|
||||
else{photo.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from imageData where id = "'+photo["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+photo.id+'", created="'+photo.created+'", edited="'+photo.edited+'", profile="0", link="'+photo["thumb"]+'", filename="'+photo.filename+'",title="", desc="'+photo.desc+'", type="'+photo.type+'", width="0", height="0", album="'+photo.album+'", location="file://'+login.imagestore+'albums/'+photo.album+'/" where id="'+photo["id"]+'"');
|
||||
} else {// use insert print('... does not exists, create it')
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,photo.id,photo.created,photo.edited,'', photo.desc, photo.album, photo.filename, photo.type, '', '',0,photo["thumb"],'file://'+login.imagestore+'albums/'+photo.album+"/"]);
|
||||
}
|
||||
})
|
||||
print("Data retrieval failure! "+ e+obj);
|
||||
}
|
||||
}})
|
||||
|
|
|
@ -344,19 +344,19 @@ function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
|||
})}
|
||||
|
||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/retweet?id="+newsid,"","POST", rootwindow,function (obj){
|
||||
Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/reblog","","POST", rootwindow,function (obj){
|
||||
var answer=JSON.parse(obj);
|
||||
if(answer.hasOwnProperty('status'))//('error' in answer.status)
|
||||
{Helperjs.showMessage("Repost",answer.status.code,rootwindow);}
|
||||
else{Helperjs.showMessage("Repost",answer.text,rootwindow)}
|
||||
else{Helperjs.showMessage("Repost",answer.content,rootwindow)}
|
||||
})
|
||||
}
|
||||
|
||||
function favorite(login,favorited,newsid,rootwindow){
|
||||
// toggle favorites
|
||||
if(favorited){ Helperjs.friendicaPostRequest(login,"/api/favorites/create?id="+newsid,"","POST", rootwindow,function (obj){
|
||||
if(favorited){ Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/bookmark","","POST", rootwindow,function (obj){
|
||||
})}
|
||||
else {Helperjs.friendicaPostRequest(login,"/api/favorites/destroy?id="+newsid,"","POST",rootwindow,function (obj){
|
||||
else {Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/unbookmark","","POST",rootwindow,function (obj){
|
||||
})}
|
||||
}
|
||||
|
||||
|
|
|
@ -455,7 +455,7 @@ function processNews(api,data){
|
|||
usermessages.push(newslist.status);
|
||||
newslist=usermessages;
|
||||
}
|
||||
if (data==""){newsBusy.running=false}
|
||||
if (data=="" || api=="/api/v1/statuses"){print("data "+data); newsBusy.running=false}
|
||||
else if (typeof(newslist)=='undefined'){
|
||||
Helperjs.showMessage(qsTr("Undefined Array Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue