Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x-super-properties header #2586

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/net/dv8tion/jda/internal/requests/Requester.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map.Entry;
Expand All @@ -65,6 +67,7 @@ public class Requester
private final Consumer<? super okhttp3.Request.Builder> customBuilder;

private final OkHttpClient httpClient;
private volatile String superProperties;

//when we actually set the shard info we can also set the mdc context map, before it makes no sense
private boolean isContextReady = false;
Expand Down Expand Up @@ -310,6 +313,38 @@ private void applyHeaders(Request<?> apiRequest, okhttp3.Request.Builder builder
}
}

public String getSuperProperties()
{
if (superProperties != null)
return superProperties;

synchronized (this)
{
if (superProperties != null)
return superProperties;

superProperties = new String(Base64.getEncoder().encode(DataObject.empty()
.put("os", "Windows")
.put("browser", "Discord Client")
.put("release_channel", "stable")
.put("client_version", "1.0.9024")
.put("os_version", "10.0.22621")
.put("os_arch", "x64")
.put("app_arch", "ia32")
.put("system_locale", "en-US")
.put("browser_user_agent", userAgent)
.put("browser_version", "22.3.26")
.put("client_build_number", 247232)
.put("native_build_number", 39566)
.put("client_event_source", null)
.put("design_id", 0)
.toJson()
), StandardCharsets.UTF_8);
}

return superProperties;
}

public OkHttpClient getHttpClient()
{
return this.httpClient;
Expand Down
Loading