File indexing completed on 2024-12-08 04:33:20
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "moderationlistmessages.h" 0007 #include "moderationmessage.h" 0008 #include "ruqola_debug.h" 0009 0010 ModerationListMessages::ModerationListMessages() = default; 0011 0012 ModerationListMessages::~ModerationListMessages() = default; 0013 0014 void ModerationListMessages::parseMessagesList(const QJsonObject &messagesObj, const QString &arrayName) 0015 { 0016 const QJsonArray messagesArray = messagesObj[arrayName.isEmpty() ? QStringLiteral("messages") : arrayName].toArray(); 0017 mListMessages.reserve(messagesArray.count()); 0018 for (const QJsonValue ¤t : messagesArray) { 0019 if (current.type() == QJsonValue::Object) { 0020 const QJsonObject messageModerationObject = current.toObject(); 0021 Message m; 0022 ModerationMessage moderationMessage; 0023 moderationMessage.parse(messageModerationObject); 0024 m.parseMessage(messageModerationObject[QLatin1String("message")].toObject(), true); 0025 m.setModerationMessage(moderationMessage); 0026 mListMessages.append(std::move(m)); 0027 } else { 0028 qCWarning(RUQOLA_LOG) << "Problem when parsing moderation message" << current; 0029 } 0030 } 0031 }