OAuth and bugfixes

This commit is contained in:
LubuWest 2023-05-24 21:40:26 +02:00
commit d43c18bb76
65 changed files with 1681 additions and 1494 deletions

View file

@ -44,10 +44,8 @@ Dialog {
modal: true
onAccepted: {
Helperjs.updateData(root.db,"contacts",login.username,"statusnet_blocking", true,function(){},"id",newsitem.user.id)
xhr.setUrl(login.server);
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setAccount(login);
xhr.setApi("/api/v1/accounts/" + newsitem.user.id + "/block");
xhr.clearParams();
xhr.post();
}
onRejected: {close()}

View file

@ -89,18 +89,13 @@ Page {
}
function showConversation(conversationIndex,newsitemobject){
xhr.setAccount(login);
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/conversation/show");
xhr.setParam("id",newsitemobject.id)
xhr.get();
}
else{
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/direct_messages/conversation");
xhr.setParam("uri",newsitemobject.statusnet_conversation_id)
xhr.get();
@ -218,11 +213,10 @@ Page {
height: 6*mm
text:qsTr("Approve")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/follow_requests/" + contact.id + "/authorize",'',"POST",root,function(returnvalue){
})
xhr.setAccount(login);
xhr.setApi("/api/v1/follow_requests/" + contact.id + "/authorize");
xhr.post();
Helperjs.deleteData(root.db,"friendshiprequests",root.login.username,function(){},"id", contact.id)
//if (rootstack.currentIndex==1){root.friendsSignal(login.username)}
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -233,11 +227,10 @@ Page {
height: 6*mm
text:qsTr("Reject")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/follow_requests/" + contact.id + "/reject",'',"POST",root,function(returnvalue){
})
xhr.setAccount(login);
xhr.setApi("/api/v1/follow_requests/" + contact.id + "/authorize");
xhr.post();
Helperjs.deleteData(root.db,"friendshiprequests",root.login.username,function(){},"id", contact.id)
//if (rootstack.currentIndex==1){root.friendsSignal(login.username)}
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -248,11 +241,10 @@ Page {
height: 6*mm
text:qsTr("Ignore")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/follow_requests/" + contact.id + "/ignore",'',"POST",root,function(returnvalue){
});
xhr.setAccount(login);
xhr.setApi("/api/v1/follow_requests/" + contact.id + "/ignore");
xhr.post();
Helperjs.deleteData(root.db,"friendshiprequests",root.login.username,function(){},"id", contact.id)
//if (rootstack.currentIndex==1){root.friendsSignal(login.username)}
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -264,12 +256,11 @@ Page {
text:qsTr("Follow")
onClicked:{
contactBusy.running=true;
Helperjs.friendicaPostRequest(login,"/api/v1/accounts/" + contact.id + "/follow",'',"POST",root,function(returnvalue){
});
xhr.setAccount(login);
xhr.setApi("/api/v1/accounts/" + contact.id + "/follow");
xhr.post();
Helperjs.updateData(root.db,"contacts",root.login.username,"isFriend",1,function(){},"id",contact.id)
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
//if (rootstack.currentIndex==1){root.friendsSignal(login.username)}
rootstackView.pop()
}
}
@ -281,11 +272,9 @@ Page {
text:qsTr("Unfollow")
onClicked:{
contactBusy.running=true;
Helperjs.friendicaPostRequest(login,"/api/v1/accounts/" + contact.id + "/unfollow",'',"POST",root,function(returnvalue){
});
xhr.setApi("/api/v1/accounts/" + contact.id + "/unfollow");
xhr.post();
Helperjs.updateData(root.db,"contacts",root.login.username,"isFriend",0,function(){},"id",contact.id)
//if (rootstack.currentIndex==1){root.friendsSignal(login.username)}
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -299,8 +288,9 @@ Page {
onClicked:{
contactBusy.running=true;
Helperjs.updateData(root.db,"contacts",root.login.username,"statusnet_blocking",true,function(){},"id",contact.id)
Helperjs.friendicaPostRequest(login,"/api/v1/accounts/" + contact.id + "/block",'',"POST",root,function(returnvalue){
});
xhr.setAccount(login);
xhr.setApi("/api/v1/accounts/" + contact.id + "/block");
xhr.post();
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -314,8 +304,9 @@ Page {
onClicked:{
contactBusy.running=true;
Helperjs.updateData(root.db,"contacts",root.login.username,"statusnet_blocking",false,function(){},"id",contact.id)
Helperjs.friendicaPostRequest(login,"/api/v1/accounts/" + contact.id + "/unblock",'',"POST",root,function(returnvalue){
});
xhr.setAccount(login);
xhr.setApi("/api/v1/accounts/" + contact.id + "/unblock");
xhr.post();
try{root.contactRefreshSignal();}catch(e){print("root.refreshSignal"+e)}
rootstackView.pop()
}
@ -368,6 +359,10 @@ Page {
if (api=="/api/statuses/user_timeline"){
Service.processNews(api,data)
}
else if (api=="/api/statuses/user_timeline"){
Service.processNews(api,data)
}
}
}
@ -402,9 +397,7 @@ Page {
}
}
Component.onCompleted: {
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/statuses/user_timeline")
xhr.setParam("user_id",contact.id)
xhr.get();

View file

@ -38,12 +38,12 @@ import "qrc:/qml/genericqml"
Page{
id:imageDialog
property var attachImageURLs: []
// property var contacts: []
// property var groups: []
// property var contact_allow:login.permissions[0]
// property var contact_deny:login.permissions[1]
// property var group_allow:login.permissions[2]
// property var group_deny:login.permissions[3]
// property var contacts: []
// property var groups: []
// property var contact_allow:login.permissions[0]
// property var contact_deny:login.permissions[1]
// property var group_allow:login.permissions[2]
// property var group_deny:login.permissions[3]
property int imageNo: 0
function uploadImage(imageid){
@ -53,10 +53,8 @@ Page{
uploadImage(imageNo);
}
} else{
xhr.setUrl(login.server);
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setAccount(login);
xhr.setApi("/api/media/upload");
xhr.clearParams();
//if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
//if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
//if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
@ -67,12 +65,9 @@ Page{
}
}
function updateAltText(imageid, media){print("media "+media + " alt_text "+imageUploadModel.get(imageid).description)
xhr.setUrl(login.server);
xhr.setLogin(login.username+":"+Qt.atob(login.password));
function updateAltText(imageid, media){
xhr.setAccount(login);
xhr.setApi("/api/media/metadata/create");
xhr.clearParams();
xhr.setParam("JSON",JSON.stringify({media_id:media,alt_text:{text:imageUploadModel.get(imageid).description}}));
xhr.postJSON();
}
@ -80,9 +75,9 @@ Page{
function attach(){
imagePicking=true;
var imagePicker = Qt.createQmlObject('import QtQuick 2.0; import "qrc:/qml/genericqml";'+
osSettings.imagePickQml+'{multiple : false;onReady: {'+
'attachImage(imageUrl)}}',imageDialog,"imagePicker");
imagePicker.pickImage()
osSettings.imagePickQml+'{multiple : false;onReady: {'+
'attachImage(imageUrl)}}',imageDialog,"imagePicker");
imagePicker.pickImage()
}
function attachImage(url){
@ -111,7 +106,7 @@ Page{
print("error "+data);
}
function onSuccess(data,api){
if (api=="/api/media/upload" ){print("data "+data);
if (api=="/api/media/upload" ){
let obj=JSON.parse(data);
messageSend.media_ids.push(obj.media_id);
if(imageUploadModel.get(imageNo).description!==""){
@ -164,13 +159,13 @@ Page{
}
BusyIndicator{
id: uploadBusy
running: false
anchors.horizontalCenter: imageUploadView.horizontalCenter
anchors.top:imageUploadView.top
anchors.topMargin: root.fontFactor*osSettings.bigFontSize
width: 2.5*root.fontFactor*osSettings.bigFontSize
height: 2.5*root.fontFactor*osSettings.bigFontSize
id: uploadBusy
running: false
anchors.horizontalCenter: imageUploadView.horizontalCenter
anchors.top:imageUploadView.top
anchors.topMargin: root.fontFactor*osSettings.bigFontSize
width: 2.5*root.fontFactor*osSettings.bigFontSize
height: 2.5*root.fontFactor*osSettings.bigFontSize
}
ListModel{
@ -268,6 +263,7 @@ Page{
width: 5*root.fontFactor*osSettings.bigFontSize
height:imageUploadView.height-3*root.fontFactor*osSettings.bigFontSize
color: Material.backgroundColor
border.color: "transparent"
text:"\u002b"
fontSize: 3*osSettings.bigFontSize
onClicked:{attach()}
@ -287,7 +283,7 @@ Page{
{newimageProgress.visible=true;
if (imageUploadModel.count>0){
uploadImage(imageNo)
}}
}}
}
}
ProgressBar{

View file

@ -90,31 +90,28 @@ Rectangle{
function statusUpdate(title,status,in_reply_to_status_id) {
//xhr.url= login.server + "/api/statuses/update.json";
try{newsBusy.running=true;conversationBusy.running=true}catch(e){}
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/statuses/update");
xhr.clearParams();
xhr.setParam("source", "Friendiqa");
xhr.setParam("htmlstatus", status);
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentId)};
if (title!=="") {xhr.setParam("title", title)};
if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
// if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
// if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
// if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
// if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
if (media_ids.length>0) {
xhr.setParam("media_ids", media_ids.join());
}
xhr.post();
Newsjs.storeHashtags(login,db,status,root)
Newsjs.storeHashtags(login,db,status,root);
media_ids=[]
}
function dmUpdate(title,text,replyto,screen_name) {
newsBusy.running=true;
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/direct_messages/new");
xhr.clearParams();
xhr.setParam("text", text);
xhr.setParam("screen_name", screen_name);
if (parentId!="") {xhr.setParam("replyto", replyto)};
@ -127,7 +124,7 @@ Rectangle{
messageSend.reply_to_user=newsitemobject.user.screen_name;
messageSend.parentId=newsitemobject.id
} else {
messageSend.state=null;
messageSend.state="";
messageSend.reply_to_user="";
messageSend.parentId="";
bodyField.text="";
@ -206,7 +203,7 @@ Rectangle{
height:stackTypeDescription.height
anchors.right: stackTypeDescription.right
anchors.rightMargin: 2*root.fontFactor*osSettings.bigFontSize
visible: newsSwipeview.currentIndex!=newsSwipeview.length-1
visible: newsSwipeview.currentIndex!=newsSwipeview.count-1
text:"\uf054"
fontColor: Material.hintTextColor
border.color: "transparent"

View file

@ -50,6 +50,7 @@ Page{
anchors.fill: parent
orientation: Qt.Horizontal
highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
spacing: root.fontFactor*osSettings.systemFontSize
model:photolistModel
delegate: photoWrapper
}

View file

@ -60,7 +60,7 @@ Rectangle{
function newstypeHandling(newstype){
try{newsBusy.running=true}catch(e){print(e)};
replySignal("");
root.replySignal("");
switch(newstype){
case "timeline":
newstab.newstabstatus="Timeline";
@ -158,10 +158,8 @@ Rectangle{
newstabstatus="Search";
newsBusy.running=true;
newsStack.updateMethodNews="refresh";
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/search");
xhr.clearParams();
xhr.setParam("q",term)
xhr.get();}
newsView.anchors.topMargin=mm
@ -242,7 +240,7 @@ Rectangle{
];
if(newsApiArray.includes(api)){
Service.processNews(api,data)
replySignal("")
root.replySignal("")
}
}
}
@ -267,7 +265,7 @@ Rectangle{
else if (newsSwipeview.stacktype=="Replies"){
Service.updateView("Replies")
}
replySignal("")
root.replySignal("")
}
}
}
@ -365,7 +363,6 @@ Rectangle{
if (newsSwipeview.stacktype=="Home"){
Newsjs.getLastNews(root.login,root.db,function(currentlastnews){
//print("currentlastnews "+currentlastnews+ " lastnewsid "+lastnewsid)
if (currentlastnews>lastnewsid){
if(currentnewstabstatus=="Timeline"){
try{ Newsjs.newsfromdb(root.db,root.login,0, function(dbnews,lastid){
@ -379,7 +376,7 @@ Rectangle{
showNews(news)});
}
} else {
Service.updateView(currentnewstabstatus)
Service.updateView(currentnewstabstatus,currentlastnews)
}
});
}

View file

@ -52,18 +52,14 @@ Rectangle{
function showConversation(conversationIndex,newsitemobject){
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/conversation/show");
xhr.setParam("id",newsitemobject.id)
xhr.setParam("count","200")
xhr.get();
}
else{
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/direct_messages/conversation");
xhr.setParam("uri",newsitemobject.statusnet_conversation_id)
xhr.get();

View file

@ -53,7 +53,8 @@ Page{
visible: video.playbackState!=MediaPlayer.PlayingState
}
Video {id:video;
Video {
id:video;
anchors.fill:parent
property string mimetype:""
onErrorChanged:{noticeText.font.pointSize=osSettings.bigFontSize;noticeText.text=errorString;}
@ -61,12 +62,6 @@ Page{
autoLoad: true
autoPlay: true
audioRole: MediaPlayer.VideoRole
// MouseArea {
// anchors.fill:parent;
// onClicked:{
// rootstackView.pop()
// }
// }
}
ProgressBar{
@ -110,12 +105,13 @@ Page{
}
// Slider{ id: videoSlider
// width: parent.width
// height: 3*mm
// anchors.top: video.bottom
// visible:video.playbackState!=MediaPlayer.StoppedState && video.seekable
// value: video.position/video.duration
// onPressed:video.seek(value*video.duration)
// }
Slider{
id: videoSlider
width: parent.width
height: 3*mm
anchors.top: video.bottom
visible:video.playbackState!=MediaPlayer.StoppedState && video.seekable
value: video.position/video.duration
onMoved: video.seek(value*video.duration)
}
}

View file

@ -38,8 +38,8 @@ import "qrc:/qml/genericqml"
Item {
id: newsitem
width: newsitemobject.hasOwnProperty("indent")&&newsitemobject.indent>0?parent.width:newsitem.ListView.view.width//parent.width//newsView.width //
height:toprow.height+friendicaActivities.height+controlrow.height+conversationColumn.height+1//Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
width: newsitemobject.hasOwnProperty("indent")&&newsitemobject.indent>0?parent.width:newsitem.ListView.view.width
height:toprow.height+friendicaActivities.height+controlrow.height+conversationColumn.height+1
property int itemindex: index
property var newsitemobject:model.newsitemobject
property string attending: ""
@ -129,7 +129,6 @@ Item {
font.pointSize: 0.6*osSettings.systemFontSize
font.family: "Noto Sans"
horizontalAlignment: Label.AlignRight
//text: (newsitemobject.in_reply_to_status_id!="null"&&newsitemobject.in_reply_to_status_id!=null)?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
text: (newsitemobject.reply_user!=false&&typeof(newsitemobject.reply_user)!="undefined")?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
}
}
@ -438,11 +437,6 @@ Item {
var component = Qt.createComponent("qrc:/qml/newsqml/BlockUser.qml");
var userblockdialog = component.createObject(root,{"newsitem": newsitemobject});
userblockdialog.open()
// try{
// var msg = {'deleteId': index, 'model': newsitem.ListView.view.model};
// conversationWorker.sendMessage(msg);
// }catch(e){print("block "+e)
// }
}
}
Action {

View file

@ -44,10 +44,8 @@ Dialog {
modal: true
onAccepted: {
let statusArray=[];statusArray.push(newsitem.id.toString());
xhr.setUrl(login.server);
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setAccount(login);
xhr.setApi("/api/v1/reports");
xhr.clearParams();
xhr.setParam("account_id",newsitem.user.id);
//xhr.setParam("status_ids",JSON.stringify(statusArray));
xhr.setParam("comment",comment.text);

View file

@ -207,7 +207,7 @@ Rectangle{
width:4.5*mm
height: 4.5*mm
textFormat:Text.RichText
font.pointSize: osSettings.osType=="Linux"?1.7*osSettings.systemFontSize:1.2*osSettings.systemFontSize
font.pointSize: osSettings.osType=="Linux"?1.7*osSettings.systemFontSize:1.4*osSettings.systemFontSize
text: emoji
MouseArea{