mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-05 17:45:49 +01:00
display full responses on vote/submit 403
This commit is contained in:
parent
b3768cb2c4
commit
f1feec008e
@ -21,12 +21,15 @@ public class Requester {
|
||||
}
|
||||
|
||||
public static String parseJson(HttpURLConnection connection) throws IOException {
|
||||
return parseJson(connection.getInputStream());
|
||||
}
|
||||
|
||||
public static String parseJson(InputStream inputStream) throws IOException {
|
||||
StringBuilder jsonBuilder = new StringBuilder();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
jsonBuilder.append(line);
|
||||
jsonBuilder.append(line).append("\n");
|
||||
}
|
||||
inputStream.close();
|
||||
return jsonBuilder.toString();
|
||||
|
@ -84,7 +84,7 @@ public class SBRequester {
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_duplicate");
|
||||
break;
|
||||
case 403:
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_forbidden");
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_forbidden", Requester.parseJson(connection.getErrorStream()));
|
||||
break;
|
||||
case 429:
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_rate_limit");
|
||||
@ -130,7 +130,7 @@ public class SBRequester {
|
||||
SponsorBlockUtils.messageToToast = str("vote_succeeded");
|
||||
break;
|
||||
case 403:
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_forbidden");
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_forbidden", Requester.parseJson(connection.getErrorStream()));
|
||||
break;
|
||||
default:
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_unknown_error", responseCode, connection.getResponseMessage());
|
||||
@ -189,6 +189,8 @@ public class SBRequester {
|
||||
}).start();
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
||||
private static HttpURLConnection getConnectionFromRoute(Route route, String... params) throws IOException {
|
||||
return Requester.getConnectionFromRoute(SPONSORBLOCK_API_URL, route, params);
|
||||
}
|
||||
|
@ -193,14 +193,14 @@
|
||||
|
||||
<string name="submit_failed_unknown_error" formatted="false">Unable to submit segments: Status: %d %s</string>
|
||||
<string name="submit_failed_rate_limit">Can\'t submit the segment.\nRate Limited (Too many from the same user or IP)</string>
|
||||
<string name="submit_failed_forbidden">Can\'t submit the segment.\nRejected by auto moderator</string>
|
||||
<string name="submit_failed_forbidden" formatted="false">Can\'t submit the segment.\n\n%s</string>
|
||||
<string name="submit_failed_duplicate">Can\'t submit the segment.\nAlready exists</string>
|
||||
<string name="submit_succeeded">Segment submitted successfully</string>
|
||||
<string name="submit_started">Submitting segment…</string>
|
||||
|
||||
<string name="vote_failed_unknown_error" formatted="false">Unable to vote for segment: Status: %d %s</string>
|
||||
<string name="vote_failed_rate_limit">Can\'t vote for segment.\nRate Limited (Too many from the same user or IP)</string>
|
||||
<string name="vote_failed_forbidden">Can\'t vote for segment.\nA moderator has decided that this segment is correct</string>
|
||||
<string name="vote_failed_forbidden" formatted="false">Can\'t vote for segment.\n\n%s</string>
|
||||
<string name="vote_succeeded">Voted successfully</string>
|
||||
<string name="vote_started">Voting for segment…</string>
|
||||
<string name="vote_upvote">Upvote</string>
|
||||
|
Loading…
Reference in New Issue
Block a user