Apply suggestions from code review
Additionally moved issue sanitization from server to client. Co-authored-by: DieGurke <maxi@kske.dev> Co-authored-by: CyB3RC0nN0R <kske@outlook.de>
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -16,7 +16,7 @@ import envoy.util.EnvoyLog;
|
||||
* <p>
|
||||
* Project: <strong>server</strong><br>
|
||||
* File: <strong>IssueProposalProcessor.java</strong><br>
|
||||
* Created: <strong>Aug 5, 2020</strong><br>
|
||||
* Created: <strong>05.08.2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
@ -30,16 +30,6 @@ public class IssueProposalProcessor implements ObjectProcessor<IssueProposal> {
|
||||
public void process(IssueProposal issueProposal, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||
// Do nothing if manually disabled
|
||||
if (!issueReportingEnabled) return;
|
||||
var issueDescription = issueProposal.getDescription();
|
||||
// Appending the submitter name, if this option was enabled
|
||||
issueDescription += issueProposal.getSubmitterName() != null
|
||||
? (issueDescription.endsWith("\n") || issueDescription.endsWith("<br>") ? "" : "<br>")
|
||||
+ String.format("Submitted by user %s.", issueProposal.getSubmitterName())
|
||||
: "";
|
||||
// Markdown does not support "\n". It uses "<br>"
|
||||
issueDescription = issueDescription.replaceAll("\n", "<br>");
|
||||
// We do not want any Windows artifacts to remain as that may cause problems
|
||||
issueDescription = issueDescription.replaceAll("\r", "");
|
||||
try {
|
||||
final var url = new URL(
|
||||
"https://git.kske.dev/api/v1/repos/zdm/envoy/issues?access_token=6d8ec2a72d64cbaf6319434aa2e7caf0130701b3");
|
||||
@ -51,7 +41,7 @@ public class IssueProposalProcessor implements ObjectProcessor<IssueProposal> {
|
||||
|
||||
final var json = String.format("{\"title\":\"%s\",\"body\":\"%s\",\"labels\":[240, %d]}",
|
||||
issueProposal.get(),
|
||||
issueDescription,
|
||||
issueProposal.getDescription(),
|
||||
// Label 240 should be user-made, label 117 bug and label 119 feature
|
||||
issueProposal.isBug() ? 117 : 119);
|
||||
try (final var os = connection.getOutputStream()) {
|
||||
@ -61,10 +51,11 @@ public class IssueProposalProcessor implements ObjectProcessor<IssueProposal> {
|
||||
final var status = connection.getResponseCode();
|
||||
if (status == 201) logger.log(Level.INFO, "Successfully created an issue");
|
||||
else logger.log(Level.WARNING,
|
||||
String.format("Tried creating an issue but received status code %d - Request params:title=%s,description=%s,json=%s",
|
||||
String.format("Tried creating an issue for %s but received status code %d - Request params:title=%s,description=%s,json=%s",
|
||||
url,
|
||||
status,
|
||||
issueProposal.get(),
|
||||
issueDescription,
|
||||
issueProposal.getDescription(),
|
||||
json));
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.WARNING, "An error occurred while creating an issue: ", e);
|
||||
|
Reference in New Issue
Block a user