Merge remote-tracking branch 'upstream/dev' into revanced_about_screen

# Conflicts:
#	app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java
This commit is contained in:
LisoUseInAIKyrios 2024-04-14 23:38:33 +04:00
commit 013fdc33d8

View File

@ -1,7 +1,7 @@
package app.revanced.integrations.youtube.returnyoutubedislike.requests; package app.revanced.integrations.youtube.returnyoutubedislike.requests;
import static app.revanced.integrations.youtube.returnyoutubedislike.requests.ReturnYouTubeDislikeRoutes.getRYDConnectionFromRoute;
import static app.revanced.integrations.shared.StringRef.str; import static app.revanced.integrations.shared.StringRef.str;
import static app.revanced.integrations.youtube.returnyoutubedislike.requests.ReturnYouTubeDislikeRoutes.getRYDConnectionFromRoute;
import android.util.Base64; import android.util.Base64;
@ -22,11 +22,11 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Objects; import java.util.Objects;
import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.shared.Utils;
import app.revanced.integrations.youtube.requests.Requester; import app.revanced.integrations.youtube.requests.Requester;
import app.revanced.integrations.youtube.returnyoutubedislike.ReturnYouTubeDislike; import app.revanced.integrations.youtube.returnyoutubedislike.ReturnYouTubeDislike;
import app.revanced.integrations.youtube.settings.Settings; import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.shared.Utils;
public class ReturnYouTubeDislikeApi { public class ReturnYouTubeDislikeApi {
/** /**
@ -279,7 +279,7 @@ public class ReturnYouTubeDislikeApi {
} }
if (responseCode == HTTP_STATUS_CODE_SUCCESS) { if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
// do not disconnect, the same server connection will likely be used again soon // Do not disconnect, the same server connection will likely be used again soon.
JSONObject json = Requester.parseJSONObject(connection); JSONObject json = Requester.parseJSONObject(connection);
try { try {
RYDVoteData votingData = new RYDVoteData(json); RYDVoteData votingData = new RYDVoteData(json);
@ -377,20 +377,17 @@ public class ReturnYouTubeDislikeApi {
connection.disconnect(); // disconnect, as no more connections will be made for a little while connection.disconnect(); // disconnect, as no more connections will be made for a little while
return null; return null;
} }
String result = null;
if (responseCode == HTTP_STATUS_CODE_SUCCESS) { if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
result = Requester.parseString(connection); Logger.printDebug(() -> "Registration confirmation successful");
if (result.equalsIgnoreCase("true")) { return userId;
Logger.printDebug(() -> "Registration confirmation successful");
return userId;
}
} }
final String resultLog = result == null ? "(no response)" : result;
// Something went wrong, might as well disconnect.
String response = Requester.parseStringAndDisconnect(connection);
Logger.printInfo(() -> "Failed to confirm registration for user: " + userId Logger.printInfo(() -> "Failed to confirm registration for user: " + userId
+ " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); + " solution: " + solution + " responseCode: " + responseCode + " response: '" + response + "''");
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
null, true); null, true);
connection.disconnect(); // something went wrong, might as well disconnect
} catch (SocketTimeoutException ex) { } catch (SocketTimeoutException ex) {
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false); handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
} catch (IOException ex) { } catch (IOException ex) {
@ -461,6 +458,7 @@ public class ReturnYouTubeDislikeApi {
String solution = solvePuzzle(challenge, difficulty); String solution = solvePuzzle(challenge, difficulty);
return confirmVote(videoId, userId, solution); return confirmVote(videoId, userId, solution);
} }
Logger.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote Logger.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote
+ " response code was: " + responseCode); + " response code was: " + responseCode);
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
@ -501,20 +499,17 @@ public class ReturnYouTubeDislikeApi {
connection.disconnect(); // disconnect, as no more connections will be made for a little while connection.disconnect(); // disconnect, as no more connections will be made for a little while
return false; return false;
} }
String result = null;
if (responseCode == HTTP_STATUS_CODE_SUCCESS) { if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
result = Requester.parseString(connection); Logger.printDebug(() -> "Vote confirm successful for video: " + videoId);
if (result.equalsIgnoreCase("true")) { return true;
Logger.printDebug(() -> "Vote confirm successful for video: " + videoId);
return true;
}
} }
final String resultLog = result == null ? "(no response)" : result;
// Something went wrong, might as well disconnect.
String response = Requester.parseStringAndDisconnect(connection);
Logger.printInfo(() -> "Failed to confirm vote for video: " + videoId Logger.printInfo(() -> "Failed to confirm vote for video: " + videoId
+ " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); + " solution: " + solution + " responseCode: " + responseCode + " response: '" + response + "'");
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
null, true); null, true);
connection.disconnect(); // something went wrong, might as well disconnect
} catch (SocketTimeoutException ex) { } catch (SocketTimeoutException ex) {
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false); handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
} catch (IOException ex) { } catch (IOException ex) {