File indexing completed on 2024-05-12 05:02:13
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "updatevideoconferencemessagejob.h" 0008 #include "rocketchataccount.h" 0009 #include "room.h" 0010 #include "ruqola_videoconference_core_debug.h" 0011 0012 UpdateVideoConferenceMessageJob::UpdateVideoConferenceMessageJob(QObject *parent) 0013 : QObject{parent} 0014 { 0015 } 0016 0017 UpdateVideoConferenceMessageJob::~UpdateVideoConferenceMessageJob() = default; 0018 0019 bool UpdateVideoConferenceMessageJob::canStart() const 0020 { 0021 return mVideoConferenceInfo.isValid() && mRocketChatAccount; 0022 } 0023 0024 void UpdateVideoConferenceMessageJob::start() 0025 { 0026 if (!canStart()) { 0027 qCWarning(RUQOLA_VIDEO_CONFERENCE_LOG) << "Impossible to start UpdateVideoConferenceMessageJob"; 0028 deleteLater(); 0029 return; 0030 } 0031 const QString roomId{mVideoConferenceInfo.roomId()}; 0032 auto room = mRocketChatAccount->room(roomId); 0033 if (room) { 0034 // qDebug() << " room" << room << " **** " << *room; 0035 auto messageModel = room->messageModel(); 0036 // Search messages 0037 if (messageModel) { 0038 Message msg = messageModel->findMessageById(mVideoConferenceInfo.messageId()); 0039 msg.setVideoConferenceInfo(std::move(mVideoConferenceInfo)); 0040 // qDebug() << " msg " << msg; 0041 mRocketChatAccount->addMessageToDataBase(room->displayFName(), msg); 0042 messageModel->addMessages({msg}); 0043 // TODO update database 0044 } 0045 } else { 0046 qCWarning(RUQOLA_VIDEO_CONFERENCE_LOG) << " impossible to return room " << roomId; 0047 } 0048 deleteLater(); 0049 } 0050 0051 VideoConferenceInfo UpdateVideoConferenceMessageJob::videoConferenceInfo() const 0052 { 0053 return mVideoConferenceInfo; 0054 } 0055 0056 void UpdateVideoConferenceMessageJob::setVideoConferenceInfo(const VideoConferenceInfo &newVideoConferenceInfo) 0057 { 0058 mVideoConferenceInfo = newVideoConferenceInfo; 0059 } 0060 0061 RocketChatAccount *UpdateVideoConferenceMessageJob::rocketChatAccount() const 0062 { 0063 return mRocketChatAccount; 0064 } 0065 0066 void UpdateVideoConferenceMessageJob::setRocketChatAccount(RocketChatAccount *newRocketChatAccount) 0067 { 0068 mRocketChatAccount = newRocketChatAccount; 0069 } 0070 0071 #include "moc_updatevideoconferencemessagejob.cpp"