join guild -> accept invite, handle group dm invites

This commit is contained in:
ouwou
2021-02-18 17:07:21 -05:00
parent 3ab3119602
commit 901028cec9
5 changed files with 42 additions and 3 deletions

View File

@@ -1,5 +1,16 @@
#include "invite.hpp"
void from_json(const nlohmann::json &j, InviteChannelData &m) {
JS_D("id", m.ID);
JS_D("type", m.Type);
JS_ON("name", m.Name);
if (j.contains("recipients") && j.at("recipients").is_null()) {
m.RecipientUsernames.emplace();
for (const auto &x : j.at("recipients"))
m.RecipientUsernames->push_back(x.at("username").get<std::string>());
}
}
void from_json(const nlohmann::json &j, InviteData &m) {
JS_D("code", m.Code);
JS_O("guild", m.Guild);
@@ -15,3 +26,14 @@ void from_json(const nlohmann::json &j, InviteData &m) {
JS_O("temporary", m.IsTemporary);
JS_O("created_at", m.CreatedAt);
}
InviteChannelData::InviteChannelData(const ChannelData &c) {
ID = c.ID;
Type = c.Type;
Name = c.Name;
if (Type == ChannelType::GROUP_DM) {
RecipientUsernames.emplace();
for (const auto &r : c.GetDMRecipients())
RecipientUsernames->push_back(r.Username);
}
}