Warning, file /network/ruqola/src/rocketchatrestapi-qt/createchannelteaminfo.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: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #include "createchannelteaminfo.h"
0007 
0008 #include <QJsonArray>
0009 #include <QJsonObject>
0010 
0011 using namespace RocketChatRestApi;
0012 
0013 bool CreateChannelTeamInfo::isValid() const
0014 {
0015     return !name.isEmpty();
0016 }
0017 
0018 bool CreateChannelTeamInfo::canStart() const
0019 {
0020     return isValid();
0021 }
0022 
0023 QJsonDocument CreateChannelTeamInfo::json() const
0024 {
0025     QJsonObject jsonObj;
0026     if (!members.isEmpty()) {
0027         jsonObj[QLatin1String("members")] = QJsonArray::fromStringList(members);
0028     }
0029     jsonObj[QLatin1String("name")] = name;
0030     if (readOnly) {
0031         jsonObj[QLatin1String("readOnly")] = true;
0032     } // Default is false
0033 
0034     if (infoType == Team) {
0035         jsonObj[QLatin1String("type")] = privateChannel ? 1 : 0;
0036     }
0037 
0038     QJsonObject extraJsonObj;
0039 
0040     if (broadcast) {
0041         extraJsonObj[QLatin1String("broadcast")] = true;
0042     } // Default is false
0043     if (encrypted) {
0044         extraJsonObj[QLatin1String("encrypted")] = true;
0045     } // Default is false
0046     if (!description.isEmpty()) {
0047         extraJsonObj[QLatin1String("description")] = description;
0048     }
0049     if (!teamId.isEmpty()) {
0050         extraJsonObj[QLatin1String("teamId")] = teamId;
0051     }
0052     jsonObj[QLatin1String("extraData")] = extraJsonObj;
0053     const QJsonDocument postData = QJsonDocument(jsonObj);
0054     return postData;
0055 }
0056 
0057 QDebug operator<<(QDebug d, const RocketChatRestApi::CreateChannelTeamInfo &t)
0058 {
0059     d << "name " << t.name;
0060     d << "description " << t.description;
0061     d << "teamId " << t.teamId;
0062     d << "members " << t.members;
0063     d << "readOnly " << t.readOnly;
0064     d << "broadcast " << t.broadcast;
0065     d << "encrypted " << t.encrypted;
0066     d << "private channel " << t.privateChannel;
0067     d << "infoType " << t.infoType;
0068     return d;
0069 }
0070 
0071 #include "moc_createchannelteaminfo.cpp"