Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Return YouTube Dislike): Do not show error toast if API…
Browse files Browse the repository at this point in the history
… success response contains new lines (#612)
  • Loading branch information
LisoUseInAIKyrios authored Apr 14, 2024
1 parent e9cd898 commit 9108205
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public static RYDVoteData fetchVotes(String videoId) {
}

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);
try {
RYDVoteData votingData = new RYDVoteData(json);
Expand Down Expand Up @@ -377,20 +377,17 @@ private static String confirmRegistration(String userId, String solution) {
connection.disconnect(); // disconnect, as no more connections will be made for a little while
return null;
}
String result = null;
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
result = Requester.parseJson(connection);
if (result.equalsIgnoreCase("true")) {
Logger.printDebug(() -> "Registration confirmation successful");
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.parseJsonAndDisconnect(connection);
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),
null, true);
connection.disconnect(); // something went wrong, might as well disconnect
} catch (SocketTimeoutException ex) {
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
} catch (IOException ex) {
Expand Down Expand Up @@ -461,6 +458,7 @@ public static boolean sendVote(String videoId, ReturnYouTubeDislike.Vote vote) {
String solution = solvePuzzle(challenge, difficulty);
return confirmVote(videoId, userId, solution);
}

Logger.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote
+ " response code was: " + responseCode);
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
Expand Down Expand Up @@ -501,20 +499,17 @@ private static boolean confirmVote(String videoId, String userId, String solutio
connection.disconnect(); // disconnect, as no more connections will be made for a little while
return false;
}
String result = null;
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
result = Requester.parseJson(connection);
if (result.equalsIgnoreCase("true")) {
Logger.printDebug(() -> "Vote confirm successful for video: " + videoId);
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.parseJsonAndDisconnect(connection);
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),
null, true);
connection.disconnect(); // something went wrong, might as well disconnect
} catch (SocketTimeoutException ex) {
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
} catch (IOException ex) {
Expand Down

0 comments on commit 9108205

Please sign in to comment.