fix presence in identify and update build number

This commit is contained in:
ouwou
2020-12-18 23:55:28 -05:00
parent 712eba816e
commit 2ec60ce5ac
5 changed files with 23 additions and 14 deletions

View File

@@ -99,3 +99,10 @@ void to_json(nlohmann::json &j, const Activity &m) {
JS_IF("instance", m.IsInstance);
JS_IF("flags", m.Flags);
}
void to_json(nlohmann::json &j, const Presence &m) {
j["activities"] = m.Activities;
j["status"] = m.Status;
j["afk"] = m.IsAFK;
j["since"] = m.Since;
}

View File

@@ -90,3 +90,12 @@ struct Activity {
friend void from_json(const nlohmann::json &j, Activity &m);
friend void to_json(nlohmann::json &j, const Activity &m);
};
struct Presence {
std::vector<Activity> Activities; // null (but never sent as such)
std::string Status;
bool IsAFK;
int Since = 0;
friend void to_json(nlohmann::json &j, const Presence &m);
};

View File

@@ -383,9 +383,9 @@ void DiscordClient::BanUser(Snowflake user_id, Snowflake guild_id) {
void DiscordClient::UpdateStatus(const std::string &status, bool is_afk, const Activity &obj) {
UpdateStatusMessage msg;
msg.Status = status;
msg.IsAFK = is_afk;
msg.Activities.push_back(obj);
msg.Presence.Status = status;
msg.Presence.IsAFK = is_afk;
msg.Presence.Activities.push_back(obj);
m_websocket.Send(nlohmann::json(msg));
}
@@ -985,7 +985,7 @@ void DiscordClient::SendIdentify() {
msg.Properties.ReferrerCurrent = "";
msg.Properties.ReferringDomainCurrent = "";
msg.Properties.ReleaseChannel = "stable";
msg.Properties.ClientBuildNumber = 73363;
msg.Properties.ClientBuildNumber = 73785;
msg.Properties.ClientEventSource = "";
msg.Presence.Status = "online";
msg.Presence.Since = 0;

View File

@@ -85,11 +85,7 @@ void to_json(nlohmann::json &j, const LazyLoadRequestMessage &m) {
void to_json(nlohmann::json &j, const UpdateStatusMessage &m) {
j["op"] = GatewayOp::UpdateStatus;
j["d"] = nlohmann::json::object();
j["d"]["activities"] = m.Activities;
j["d"]["status"] = m.Status;
j["d"]["afk"] = m.IsAFK;
j["d"]["since"] = nullptr;
j["d"] = m.Presence;
}
void from_json(const nlohmann::json &j, ReadyEventData &m) {

View File

@@ -145,10 +145,7 @@ struct LazyLoadRequestMessage {
};
struct UpdateStatusMessage {
std::vector<Activity> Activities; // null (but never sent as such)
std::string Status;
bool IsAFK;
int Since = 0;
Presence Presence;
friend void to_json(nlohmann::json &j, const UpdateStatusMessage &m);
};
@@ -209,7 +206,7 @@ struct ClientStateProperties {
struct IdentifyMessage : GatewayMessage {
std::string Token;
IdentifyProperties Properties;
UpdateStatusMessage Presence;
Presence Presence;
ClientStateProperties ClientState;
bool DoesSupportCompression = false;
int Capabilities;