Reuse encoder for debugs

This commit is contained in:
Vankka 2024-06-22 11:12:33 +03:00
parent 5ffc40b96f
commit 7fc39b1d53
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
2 changed files with 4 additions and 2 deletions

View File

@ -86,7 +86,7 @@ public class DebugCommand extends CombinedCommand {
}
private static final String URL_FORMAT = DiscordSRV.WEBSITE + "/debug/%s#%s";
private static final Base64.Encoder KEY_ENCODER = Base64.getUrlEncoder().withoutPadding();
public static final Base64.Encoder KEY_ENCODER = Base64.getUrlEncoder().withoutPadding();
private final PasteService pasteService;

View File

@ -53,6 +53,8 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static com.discordsrv.common.command.combined.commands.DebugCommand.KEY_ENCODER;
public class DebugReport {
private static final int BIG_FILE_SPLIT_SIZE = 50000;
@ -101,7 +103,7 @@ public class DebugReport {
try {
Paste paste = service.uploadFile(convertToJson(file).toString().getBytes(StandardCharsets.UTF_8));
node.put("url", paste.url());
node.put("decryption_key", new String(Base64.getUrlEncoder().encode(paste.decryptionKey()), StandardCharsets.UTF_8));
node.put("decryption_key", new String(KEY_ENCODER.encode(paste.decryptionKey()), StandardCharsets.UTF_8));
node.put("length", length);
} catch (Throwable e) {
node.put("content", "Failed to upload file\n\n" + ExceptionUtils.getStackTrace(e));