mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 18:51:26 +00:00
added OS_NAME, OS_VERSION and OS_ARCH to user-agent
This commit is contained in:
@@ -2,6 +2,7 @@ package org.cryptomator.ui.error;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.common.Environment;
|
||||
import org.cryptomator.common.ErrorCode;
|
||||
import org.cryptomator.common.Nullable;
|
||||
@@ -42,7 +43,7 @@ public class ErrorController implements FxController {
|
||||
|
||||
private static final ObjectMapper JSON = new ObjectMapper();
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ErrorController.class);
|
||||
private static final String USER_AGENT_VERSION_FORMAT = "Cryptomator/%s (Build %s)";
|
||||
private static final String USER_AGENT_VERSION_FORMAT = "Cryptomator/%s (Build %s) %s %s (%s)";
|
||||
private static final String ERROR_CODES_URL_FORMAT = "https://api.cryptomator.org/desktop/error-codes.json?error-code=%s";
|
||||
private static final String SEARCH_URL_FORMAT = "https://github.com/cryptomator/cryptomator/discussions/categories/errors?discussions_q=category:Errors+%s";
|
||||
private static final String REPORT_URL_FORMAT = "https://github.com/cryptomator/cryptomator/discussions/new?category=Errors&title=Error+%s&body=%s";
|
||||
@@ -143,11 +144,17 @@ public class ErrorController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void lookUpSolution() {
|
||||
String userAgent = USER_AGENT_VERSION_FORMAT.formatted( //
|
||||
environment.getAppVersion(), //
|
||||
environment.getBuildNumber().orElse("undefined"), //
|
||||
SystemUtils.OS_NAME, //
|
||||
SystemUtils.OS_VERSION, //
|
||||
SystemUtils.OS_ARCH); //
|
||||
isLoadingHttpResponse.set(true);
|
||||
askedForLookupDatabasePermission.set(true);
|
||||
HttpClient httpClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
|
||||
HttpRequest httpRequest = HttpRequest.newBuilder()//
|
||||
.header("User-Agent", USER_AGENT_VERSION_FORMAT.formatted(environment.getAppVersion(),environment.getBuildNumber().orElse("undefined")))
|
||||
.header("User-Agent", userAgent)
|
||||
.uri(URI.create(ERROR_CODES_URL_FORMAT.formatted(URLEncoder.encode(errorCode.toString(),StandardCharsets.UTF_8))))//
|
||||
.build();
|
||||
httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofInputStream())//
|
||||
|
||||
Reference in New Issue
Block a user