forked from OpenGamers/abaddon
handle RELATIONSHIP_ADD
This commit is contained in:
parent
469053a144
commit
925405826a
@ -1038,6 +1038,9 @@ void DiscordClient::HandleGatewayMessage(std::string str) {
|
||||
case GatewayEvent::RELATIONSHIP_REMOVE: {
|
||||
HandleGatewayRelationshipRemove(m);
|
||||
} break;
|
||||
case GatewayEvent::RELATIONSHIP_ADD: {
|
||||
HandleGatewayRelationshipAdd(m);
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
@ -1485,6 +1488,13 @@ void DiscordClient::HandleGatewayRelationshipRemove(const GatewayMessage &msg) {
|
||||
m_signal_relationship_remove.emit(data.ID, data.Type);
|
||||
}
|
||||
|
||||
void DiscordClient::HandleGatewayRelationshipAdd(const GatewayMessage &msg) {
|
||||
RelationshipAddData data = msg.Data;
|
||||
m_store.SetUser(data.ID, data.User);
|
||||
m_user_relationships[data.ID] = data.Type;
|
||||
m_signal_relationship_add.emit(std::move(data));
|
||||
}
|
||||
|
||||
void DiscordClient::HandleGatewayReadySupplemental(const GatewayMessage &msg) {
|
||||
ReadySupplementalData data = msg.Data;
|
||||
for (const auto &p : data.MergedPresences.Friends) {
|
||||
@ -1821,6 +1831,7 @@ void DiscordClient::LoadEventMap() {
|
||||
m_event_map["GUILD_JOIN_REQUEST_UPDATE"] = GatewayEvent::GUILD_JOIN_REQUEST_UPDATE;
|
||||
m_event_map["GUILD_JOIN_REQUEST_DELETE"] = GatewayEvent::GUILD_JOIN_REQUEST_DELETE;
|
||||
m_event_map["RELATIONSHIP_REMOVE"] = GatewayEvent::RELATIONSHIP_REMOVE;
|
||||
m_event_map["RELATIONSHIP_ADD"] = GatewayEvent::RELATIONSHIP_ADD;
|
||||
}
|
||||
|
||||
DiscordClient::type_signal_gateway_ready DiscordClient::signal_gateway_ready() {
|
||||
@ -1947,6 +1958,10 @@ DiscordClient::type_signal_relationship_remove DiscordClient::signal_relationshi
|
||||
return m_signal_relationship_remove;
|
||||
}
|
||||
|
||||
DiscordClient::type_signal_relationship_add DiscordClient::signal_relationship_add() {
|
||||
return m_signal_relationship_add;
|
||||
}
|
||||
|
||||
DiscordClient::type_signal_message_sent DiscordClient::signal_message_sent() {
|
||||
return m_signal_message_sent;
|
||||
}
|
||||
|
@ -223,6 +223,7 @@ private:
|
||||
void HandleGatewayGuildJoinRequestUpdate(const GatewayMessage &msg);
|
||||
void HandleGatewayGuildJoinRequestDelete(const GatewayMessage &msg);
|
||||
void HandleGatewayRelationshipRemove(const GatewayMessage &msg);
|
||||
void HandleGatewayRelationshipAdd(const GatewayMessage &msg);
|
||||
void HandleGatewayReadySupplemental(const GatewayMessage &msg);
|
||||
void HandleGatewayReconnect(const GatewayMessage &msg);
|
||||
void HandleGatewayInvalidSession(const GatewayMessage &msg);
|
||||
@ -315,9 +316,10 @@ public:
|
||||
typedef sigc::signal<void, GuildJoinRequestUpdateData> type_signal_guild_join_request_update;
|
||||
typedef sigc::signal<void, GuildJoinRequestDeleteData> type_signal_guild_join_request_delete;
|
||||
typedef sigc::signal<void, Snowflake, RelationshipType> type_signal_relationship_remove;
|
||||
typedef sigc::signal<void, RelationshipAddData> type_signal_relationship_add;
|
||||
typedef sigc::signal<void, Message> type_signal_message_sent;
|
||||
typedef sigc::signal<void, std::string /* nonce */, float /* retry_after */> type_signal_message_send_fail; // retry after param will be 0 if it failed for a reason that isnt slowmode
|
||||
typedef sigc::signal<void, bool, GatewayCloseCode> type_signal_disconnected; // bool true if reconnecting
|
||||
typedef sigc::signal<void, bool, GatewayCloseCode> type_signal_disconnected; // bool true if reconnecting
|
||||
typedef sigc::signal<void> type_signal_connected;
|
||||
|
||||
type_signal_gateway_ready signal_gateway_ready();
|
||||
@ -349,6 +351,7 @@ public:
|
||||
type_signal_guild_join_request_update signal_guild_join_request_update();
|
||||
type_signal_guild_join_request_delete signal_guild_join_request_delete();
|
||||
type_signal_relationship_remove signal_relationship_remove();
|
||||
type_signal_relationship_add signal_relationship_add();
|
||||
type_signal_message_sent signal_message_sent();
|
||||
type_signal_message_send_fail signal_message_send_fail();
|
||||
type_signal_disconnected signal_disconnected();
|
||||
@ -384,6 +387,7 @@ protected:
|
||||
type_signal_guild_join_request_update m_signal_guild_join_request_update;
|
||||
type_signal_guild_join_request_delete m_signal_guild_join_request_delete;
|
||||
type_signal_relationship_remove m_signal_relationship_remove;
|
||||
type_signal_relationship_add m_signal_relationship_add;
|
||||
type_signal_message_sent m_signal_message_sent;
|
||||
type_signal_message_send_fail m_signal_message_send_fail;
|
||||
type_signal_disconnected m_signal_disconnected;
|
||||
|
@ -457,3 +457,9 @@ void from_json(const nlohmann::json &j, RelationshipRemoveData &m) {
|
||||
JS_D("id", m.ID);
|
||||
JS_D("type", m.Type);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, RelationshipAddData &m) {
|
||||
JS_D("id", m.ID);
|
||||
JS_D("type", m.Type);
|
||||
JS_D("user", m.User);
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ enum class GatewayEvent : int {
|
||||
GUILD_JOIN_REQUEST_UPDATE,
|
||||
GUILD_JOIN_REQUEST_DELETE,
|
||||
RELATIONSHIP_REMOVE,
|
||||
RELATIONSHIP_ADD,
|
||||
};
|
||||
|
||||
enum class GatewayCloseCode : uint16_t {
|
||||
@ -634,3 +635,13 @@ struct RelationshipRemoveData {
|
||||
|
||||
friend void from_json(const nlohmann::json &j, RelationshipRemoveData &m);
|
||||
};
|
||||
|
||||
struct RelationshipAddData {
|
||||
Snowflake ID;
|
||||
// Nickname; same deal as the other comment somewhere else
|
||||
RelationshipType Type;
|
||||
UserData User;
|
||||
// std::optional<bool> ShouldNotify; // i guess if the client should send a notification. not worth caring about
|
||||
|
||||
friend void from_json(const nlohmann::json &j, RelationshipAddData &m);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user