matrixion/src/Community.cc

34 lines
1.1 KiB
C++
Raw Normal View History

2018-01-09 16:07:32 +03:00
#include "include/Community.h"
#include <QJsonArray>
#include <QJsonValue>
void
Community::parseProfile(const QJsonObject &profile)
{
if (profile["name"].type() == QJsonValue::Type::String)
2018-01-09 16:07:32 +03:00
name_ = profile["name"].toString();
else
2018-01-09 16:07:32 +03:00
name_ = "Unnamed Community"; // TODO: what is correct here?
if (profile["avatar_url"].type() == QJsonValue::Type::String)
2018-01-09 16:07:32 +03:00
avatar_ = QUrl(profile["avatar_url"].toString());
if (profile["short_description"].type() == QJsonValue::Type::String)
2018-01-09 16:07:32 +03:00
short_description_ = profile["short_description"].toString();
if (profile["long_description"].type() == QJsonValue::Type::String)
2018-01-09 16:07:32 +03:00
long_description_ = profile["long_description"].toString();
}
void
Community::parseRooms(const QJsonObject &rooms)
{
rooms_.clear();
for (auto const &room : rooms["chunk"].toArray()) {
if (room.toObject().contains("room_id"))
rooms_.emplace_back(room.toObject()["room_id"].toString());
2018-01-09 16:07:32 +03:00
}
}