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 
0007 #include "moderationmessage.h"
0008 #include <QJsonObject>
0009 ModerationMessage::ModerationMessage() = default;
0010 
0011 ModerationMessage::~ModerationMessage() = default;
0012 
0013 QString ModerationMessage::moderationId() const
0014 {
0015     return mModerationId;
0016 }
0017 
0018 void ModerationMessage::setModerationId(const QString &newModerationId)
0019 {
0020     mModerationId = newModerationId;
0021 }
0022 
0023 void ModerationMessage::parse(const QJsonObject &obj)
0024 {
0025     mModerationId = obj[QLatin1String("_id")].toString();
0026     // TODO add timestamp
0027     const QJsonObject messageObject = obj[QLatin1String("message")].toObject();
0028     parseRoom(obj[QLatin1String("room")].toObject());
0029 }
0030 
0031 void ModerationMessage::parseRoom(const QJsonObject &roomObj)
0032 {
0033     mRoomId = roomObj[QLatin1String("_id")].toString();
0034     mRoomName = roomObj[QLatin1String("name")].toString();
0035     mRoomFName = roomObj[QLatin1String("fname")].toString();
0036     // TODO
0037 }
0038 
0039 QString ModerationMessage::roomFName() const
0040 {
0041     return mRoomFName;
0042 }
0043 
0044 void ModerationMessage::setRoomFName(const QString &newRoomFName)
0045 {
0046     mRoomFName = newRoomFName;
0047 }
0048 
0049 bool ModerationMessage::isEmpty() const
0050 {
0051     return mModerationId.isEmpty();
0052 }
0053 
0054 QString ModerationMessage::roomId() const
0055 {
0056     return mRoomId;
0057 }
0058 
0059 void ModerationMessage::setRoomId(const QString &newRoomId)
0060 {
0061     mRoomId = newRoomId;
0062 }
0063 
0064 QString ModerationMessage::roomName() const
0065 {
0066     return mRoomName;
0067 }
0068 
0069 void ModerationMessage::setRoomName(const QString &newRoomName)
0070 {
0071     mRoomName = newRoomName;
0072 }
0073 
0074 QDebug operator<<(QDebug d, const ModerationMessage &t)
0075 {
0076     d.space() << "mRoomName" << t.roomName();
0077     d.space() << "mRoomId" << t.roomId();
0078     d.space() << "mRoomFName" << t.roomFName();
0079     return d;
0080 }