fix(YouTube - Return YouTube Dislike): Do not show error toast if API success response contains new lines (#612)

This commit is contained in:
LisoUseInAIKyrios 2024-04-14 23:37:17 +04:00 committed by GitHub
parent e9cd898651
commit 9108205445
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 19 deletions

View File

@ -279,7 +279,7 @@ public class ReturnYouTubeDislikeApi {
}
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);
@ -377,20 +377,17 @@ public class ReturnYouTubeDislikeApi {
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) {
@ -461,6 +458,7 @@ public class ReturnYouTubeDislikeApi {
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),
@ -501,20 +499,17 @@ public class ReturnYouTubeDislikeApi {
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) {