File indexing completed on 2024-12-08 10:25:54

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include "user.h"
0011 #include <QDebug>
0012 #include <QJsonDocument>
0013 #include <QString>
0014 class QDateTime;
0015 class LIBRUQOLACORE_TESTS_EXPORT RocketChatMessage
0016 {
0017     Q_GADGET
0018 public:
0019     RocketChatMessage();
0020     ~RocketChatMessage() = default;
0021 
0022     struct RocketChatMessageResult {
0023         QString method;
0024         QString result;
0025         QJsonDocument jsonDocument;
0026     };
0027 
0028     void setJsonFormat(QJsonDocument::JsonFormat jsonFormat);
0029 
0030     [[nodiscard]] RocketChatMessageResult generateMethod(const QString &method, const QJsonDocument &params, quint64 id);
0031     [[nodiscard]] RocketChatMessage::RocketChatMessageResult setRoomEncrypted(const QString &roomId, bool encrypted, quint64 id);
0032     [[nodiscard]] RocketChatMessage::RocketChatMessageResult joinRoom(const QString &roomId, const QString &accessCode, quint64 id);
0033     [[nodiscard]] RocketChatMessage::RocketChatMessageResult informTypingStatus(const QString &roomId, const QString &userId, bool typingStatus, quint64 id);
0034     [[nodiscard]] RocketChatMessage::RocketChatMessageResult setDefaultStatus(User::PresenceStatus status, quint64 id);
0035     [[nodiscard]] RocketChatMessage::RocketChatMessageResult openDirectChannel(const QString &username, quint64 id);
0036     [[nodiscard]] RocketChatMessage::RocketChatMessageResult createJitsiConfCall(const QString &roomId, quint64 id);
0037     [[nodiscard]] RocketChatMessage::RocketChatMessageResult userAutocomplete(const QString &searchText, const QString &exception, quint64 id);
0038     [[nodiscard]] RocketChatMessage::RocketChatMessageResult unsubscribe(quint64 id);
0039     [[nodiscard]] RocketChatMessage::RocketChatMessageResult blockUser(const QString &rid, const QString &userId, quint64 id);
0040     [[nodiscard]] RocketChatMessage::RocketChatMessageResult unblockUser(const QString &rid, const QString &userId, quint64 id);
0041 
0042     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0043     searchRoomUsers(const QString &roomId, const QString &pattern, const QString &exceptions, bool searchUser, bool searchRoom, quint64 id);
0044     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0045     inputChannelAutocomplete(const QString &roomId, const QString &pattern, const QString &exceptions, quint64 id);
0046     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0047     inputUserAutocomplete(const QString &roomId, const QString &pattern, const QString &exceptions, quint64 id);
0048 
0049     [[nodiscard]] RocketChatMessage::RocketChatMessageResult deleteFileMessage(const QString &fileId, quint64 id);
0050 
0051     [[nodiscard]] RocketChatMessage::RocketChatMessageResult roomNameExists(const QString &roomName, quint64 id);
0052 
0053     [[nodiscard]] RocketChatMessage::RocketChatMessageResult streamNotifyUserOtrEnd(const QString &userFrom, const QString &userTo, quint64 id);
0054 
0055     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0056     streamNotifyUserOtrHandshake(const QString &userFrom, const QString &userTo, const QString &publicKeys, quint64 id);
0057 
0058     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0059     streamNotifyUserOtrAcknowledge(const QString &roomId, const QString &userId, const QString &publicKeys, quint64 id);
0060 
0061     [[nodiscard]] RocketChatMessage::RocketChatMessageResult deleteCustomSound(const QString &identifier, quint64 id);
0062 
0063     [[nodiscard]] RocketChatMessage::RocketChatMessageResult uploadCustomSound(const QByteArray &sound, quint64 id);
0064 
0065     [[nodiscard]] RocketChatMessage::RocketChatMessageResult listCustomSounds(quint64 id);
0066 
0067     [[nodiscard]] RocketChatMessage::RocketChatMessageResult enable2fa(quint64 id);
0068 
0069     [[nodiscard]] RocketChatMessage::RocketChatMessageResult disable2fa(const QString &code, quint64 id);
0070     [[nodiscard]] RocketChatMessage::RocketChatMessageResult validateTempToken2fa(const QString &code, quint64 id);
0071 
0072     [[nodiscard]] RocketChatMessage::RocketChatMessageResult regenerateCodes2fa(const QString &code, quint64 id);
0073 
0074     [[nodiscard]] RocketChatMessage::RocketChatMessageResult deleteOAuthApp(const QString &appId, quint64 id);
0075 
0076     [[nodiscard]] RocketChatMessage::RocketChatMessageResult addOAuthApp(const QString &name, bool active, const QString &redirectUrl, quint64 id);
0077     [[nodiscard]] RocketChatMessage::RocketChatMessageResult updateOAuthApp(const QString &name, bool active, const QString &redirectUrl, quint64 id);
0078 
0079     [[nodiscard]] RocketChatMessage::RocketChatMessageResult setAdminStatus(const QString &userId, bool admin, quint64 id);
0080 
0081     [[nodiscard]] RocketChatMessage::RocketChatMessageResult openRoom(const QString &roomId, quint64 id);
0082 
0083     [[nodiscard]] RocketChatMessage::RocketChatMessageResult getRoomById(const QString &roomId, quint64 id);
0084 
0085     [[nodiscard]] RocketChatMessage::RocketChatMessageResult bannerDismiss(const QString &bannerId, quint64 id);
0086 
0087     [[nodiscard]] RocketChatMessage::RocketChatMessageResult licenseGetModules(quint64 id);
0088 
0089     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0090     videoConferenceAccepted(const QString &roomId, const QString &callId, const QString &userId, quint64 id);
0091 
0092     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0093     videoConferenceRejected(const QString &roomId, const QString &callId, const QString &userId, quint64 id);
0094 
0095     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0096     videoConferenceCall(const QString &roomId, const QString &callId, const QString &userId, quint64 id);
0097 
0098     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0099     videoConferenceConfirmed(const QString &roomId, const QString &callId, const QString &userId, quint64 id);
0100 
0101 private:
0102     Q_DISABLE_COPY(RocketChatMessage)
0103     [[nodiscard]] QJsonValue toJsonDateTime(const QDateTime &dateTime);
0104     [[nodiscard]] RocketChatMessage::RocketChatMessageResult subscribe(const QString &name, const QJsonDocument &params, quint64 id);
0105     [[nodiscard]] RocketChatMessage::RocketChatMessageResult saveRoomSettings(const QString &key, const QString &roomId, const QJsonValue &value, quint64 id);
0106     QJsonDocument::JsonFormat mJsonFormat = QJsonDocument::Compact;
0107     [[nodiscard]] RocketChatMessage::RocketChatMessageResult
0108     generateVideoConferenceAction(const QString &action, const QString &roomId, const QString &callId, const QString &userId, quint64 id);
0109 };
0110 
0111 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const RocketChatMessage::RocketChatMessageResult &t);