Skip to content

Commit

Permalink
Platform 8 update: Port FreshRSS plugin to Soup 3 (#32)
Browse files Browse the repository at this point in the history
* Fix some errors for FreshRSS

* Add return type to auth signal handler
  • Loading branch information
dar5hak authored Oct 6, 2024
1 parent 246b53f commit 958ea90
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions plugins/backend/fresh/freshConnection.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ public class FeedReader.freshConnection {
m_settingsTweaks = new GLib.Settings("com.github.suzie97.communique.tweaks");
m_session = new Soup.Session();
m_session.user_agent = Constants.USER_AGENT;
m_session.authenticate.connect((msg, auth, retrying) => {
if(m_utils.getHtaccessUser() == "")
{
Logger.error("fresh Session: need Authentication");
}
else if(!retrying)
{
auth.authenticate(m_utils.getHtaccessUser(), m_utils.getHtaccessPasswd());
}
});
}

public LoginResponse getSID()
{
var message = new Soup.Message("POST", m_utils.getURL()+"accounts/ClientLogin");

message.authenticate.connect((auth, retrying) => {
if(m_utils.getHtaccessUser() == "") {
Logger.error("fresh Session: need Authentication");
} else if(!retrying) {
auth.authenticate(m_utils.getHtaccessUser(), m_utils.getHtaccessPasswd());
return true;
}
return false;
});

var msg = new freshMessage();
msg.add("Email", m_utils.getUser());
msg.add("Passwd", m_utils.getPasswd());

message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, msg.get().data);
message.set_request_body_from_bytes("application/x-www-form-urlencoded", new Bytes(msg.get().data));
var response_body = m_session.send_and_read(message);

if(message.status_code != 200)
Expand Down Expand Up @@ -91,7 +91,7 @@ public class FeedReader.freshConnection {
message.request_headers.append("Authorization","GoogleLogin auth=%s".printf(m_utils.getToken()));
message.request_headers.append("Content-Type", type);

message.request_body.append_take(input.data);
message.set_request_body_from_bytes(type, new Bytes(input.data));
var response_body = m_session.send_and_read(message);

if(message.status_code != 200)
Expand Down

0 comments on commit 958ea90

Please sign in to comment.