Warning, file /network/ruqola/src/core/manageloadhistoryparsesyncmessagesutils.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "manageloadhistoryparsesyncmessagesutils.h" 0008 #include "rocketchataccount.h" 0009 0010 ManageLoadHistoryParseSyncMessagesUtils::ManageLoadHistoryParseSyncMessagesUtils(RocketChatAccount *account) 0011 : mRocketChatAccount(account) 0012 { 0013 } 0014 0015 ManageLoadHistoryParseSyncMessagesUtils::~ManageLoadHistoryParseSyncMessagesUtils() = default; 0016 0017 QStringList ManageLoadHistoryParseSyncMessagesUtils::deletedMessages() const 0018 { 0019 return mDeletedMessages; 0020 } 0021 0022 void ManageLoadHistoryParseSyncMessagesUtils::setDeletedMessages(const QStringList &newDeletedMessages) 0023 { 0024 mDeletedMessages = newDeletedMessages; 0025 } 0026 0027 QVector<Message> ManageLoadHistoryParseSyncMessagesUtils::updatesMessages() const 0028 { 0029 return mUpdatesMessages; 0030 } 0031 0032 void ManageLoadHistoryParseSyncMessagesUtils::setUpdatesMessages(const QVector<Message> &newUpdatesMessages) 0033 { 0034 mUpdatesMessages = newUpdatesMessages; 0035 } 0036 0037 void ManageLoadHistoryParseSyncMessagesUtils::parse(const QJsonObject &obj) 0038 { 0039 mDeletedMessages.clear(); 0040 mUpdatesMessages.clear(); 0041 const QJsonObject result = obj[QLatin1String("result")].toObject(); 0042 const QJsonArray deleteArray = result[QLatin1String("deleted")].toArray(); 0043 for (int i = 0, total = deleteArray.size(); i < total; ++i) { 0044 const QJsonObject o = deleteArray.at(i).toObject(); 0045 mDeletedMessages.append(o[QLatin1String("_id")].toString()); 0046 } 0047 0048 QVector<Message> updatedMessages; 0049 const QJsonArray updatedArray = result[QLatin1String("updated")].toArray(); 0050 for (int i = 0, total = updatedArray.size(); i < total; ++i) { 0051 const QJsonObject o = updatedArray.at(i).toObject(); 0052 Message m(mRocketChatAccount ? mRocketChatAccount->emojiManager() : nullptr); 0053 m.parseMessage(o, true); 0054 updatedMessages.append(m); 0055 } 0056 mUpdatesMessages = std::move(updatedMessages); 0057 }