Use New 7TV Cosmetics System (#4512)
* feat(seventv): use new cosmetics system * chore: add changelog entry * fix: old `clang-format` * fix: small suggestions pt1 * refactor: add 7tv api wrapper * fix: small clang-tidy things * fix: remove unused constants * fix: old clangtidy * refactor: rename * fix: increase interval to 60s * fix: newline * fix: Twitch * docs: add comment * fix: remove v2 badges endpoint * fix: deadlock This is actually really sad. * fix: remove api entry * fix: old clang-format * Sort functions in SeventvBadges.hpp/cpp * Remove unused vector include * Add comments to SeventvBadges.hpp functions * Rename `addBadge` to `registerBadge` * fix: cleanup eventloop * ci(test): add timeout --------- Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "providers/seventv/eventapi/Dispatch.hpp"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace chatterino::seventv::eventapi {
|
||||
@@ -91,4 +93,45 @@ bool UserConnectionUpdateDispatch::validate() const
|
||||
!this->emoteSetID.isEmpty();
|
||||
}
|
||||
|
||||
CosmeticCreateDispatch::CosmeticCreateDispatch(const Dispatch &dispatch)
|
||||
: data(dispatch.body["object"]["data"].toObject())
|
||||
, kind(magic_enum::enum_cast<CosmeticKind>(
|
||||
dispatch.body["object"]["kind"].toString().toStdString())
|
||||
.value_or(CosmeticKind::INVALID))
|
||||
{
|
||||
}
|
||||
|
||||
bool CosmeticCreateDispatch::validate() const
|
||||
{
|
||||
return !this->data.empty() && this->kind != CosmeticKind::INVALID;
|
||||
}
|
||||
|
||||
EntitlementCreateDeleteDispatch::EntitlementCreateDeleteDispatch(
|
||||
const Dispatch &dispatch)
|
||||
{
|
||||
const auto obj = dispatch.body["object"].toObject();
|
||||
this->refID = obj["ref_id"].toString();
|
||||
this->kind = magic_enum::enum_cast<CosmeticKind>(
|
||||
obj["kind"].toString().toStdString())
|
||||
.value_or(CosmeticKind::INVALID);
|
||||
|
||||
const auto userConnections = obj["user"]["connections"].toArray();
|
||||
for (const auto &connectionJson : userConnections)
|
||||
{
|
||||
const auto connection = connectionJson.toObject();
|
||||
if (connection["platform"].toString() == "TWITCH")
|
||||
{
|
||||
this->userID = connection["id"].toString();
|
||||
this->userName = connection["username"].toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EntitlementCreateDeleteDispatch::validate() const
|
||||
{
|
||||
return !this->userID.isEmpty() && !this->userName.isEmpty() &&
|
||||
!this->refID.isEmpty() && this->kind != CosmeticKind::INVALID;
|
||||
}
|
||||
|
||||
} // namespace chatterino::seventv::eventapi
|
||||
|
||||
Reference in New Issue
Block a user