Skip to content

Commit

Permalink
Merge branch 'task/cht-1404-deprecate-remove-sched-meeting' into 'dev…
Browse files Browse the repository at this point in the history
…elop'

CHT-1404. Deprecate MegaChat::removeScheduledMeeting

See merge request megachat/MEGAchat!2030
  • Loading branch information
jgandres committed Jan 22, 2025
2 parents cea9b5e + cc52640 commit 0e2c2b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 68 deletions.
3 changes: 0 additions & 3 deletions examples/qtmegachatapi/chatItemWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,6 @@ void ChatItemWidget::contextMenuEvent(QContextMenuEvent *event)
auto actUpdateMeetingOccurr = roomMenu->addAction(tr("Update scheduled meeting occurrence"));
connect(actUpdateMeetingOccurr, SIGNAL(triggered()), mController, SLOT(updateScheduledMeetingOccurrence()));

auto actDelSchedMeeting = roomMenu->addAction(tr("Delete scheduled meeting"));
connect(actDelSchedMeeting, SIGNAL(triggered()), mController, SLOT(removeScheduledMeeting()));

auto actFetchSchedMeeting = roomMenu->addAction(tr("Fetch scheduled meetings"));
connect(actFetchSchedMeeting, SIGNAL(triggered()), mController, SLOT(fetchScheduledMeeting()));

Expand Down
6 changes: 0 additions & 6 deletions examples/qtmegachatapi/listItemController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ void ChatListItemController::updateScheduledMeeting()
cancelled, sm->flags(), sm->rules(),
updateChatTitle == "y");
}
void ChatListItemController::removeScheduledMeeting()
{
std::string aux = mMainWindow->mApp->getText("Sched meeting Id to remove: ", false).c_str();
uint64_t schedId = mMegaApi->base64ToUserHandle(aux.c_str());
mMegaApi->removeScheduledMeeting(mItemId, schedId);
}

void ChatListItemController::fetchScheduledMeeting()
{
Expand Down
1 change: 0 additions & 1 deletion examples/qtmegachatapi/listItemController.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ChatListItemController : public QObject,
public slots:
void updateScheduledMeeting();
void updateScheduledMeetingOccurrence();
void removeScheduledMeeting();
void fetchScheduledMeeting();
void fetchScheduledMeetingEvents();
void leaveGroupChat();
Expand Down
10 changes: 8 additions & 2 deletions src/megachatapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4985,8 +4985,9 @@ class MegaChatApi
/**
* @brief Removes a scheduled meeting by scheduled meeting id and chatid
*
* The associated request type with this request is MegaChatRequest::TYPE_DELETE_SCHEDULED_MEETING
* Valid data in the MegaChatRequest object received on callbacks:
* The associated request type with this request is
* MegaChatRequest::TYPE_DELETE_SCHEDULED_MEETING Valid data in the MegaChatRequest object
* received on callbacks:
* - MegaChatRequest::getChatHandle - Returns the handle of the chatroom
* - MegaChatRequest::getUserHandle - Returns the scheduled meeting id
*
Expand All @@ -4997,7 +4998,12 @@ class MegaChatApi
* @param chatid MegaChatHandle that identifies a chat room
* @param schedId MegaChatHandle that identifies a scheduled meeting
* @param listener MegaChatRequestListener to track this request
*
* @deprecated This function is deprecated. Please don't use it in new code.
* Use createOrUpdateScheduledMeeting and set cancelled flag `True` at MegaScheduledMeeting.
* Note: You can use MegaScheduledMeeting::createInstance with cancelled param `True
*/
MEGA_DEPRECATED
void removeScheduledMeeting(MegaChatHandle chatid, MegaChatHandle schedId, MegaChatRequestListener* listener = NULL);

/**
Expand Down
62 changes: 6 additions & 56 deletions tests/sdk_test/sdk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8086,8 +8086,6 @@ TEST_F(MegaChatApiTest, DISABLED_WaitingRoomsTimeout)
* Test 8. A Cancels previous scheduled meeting occurrence
* Test 9. A Sets negative offset at byMonthWeekDay
* Test 10. A Cancels entire series
* Test 11. A Deletes scheduled meeting with invalid schedId (Error)
* Test 12. A Deletes scheduled meeting
*/
TEST_F(MegaChatApiTest, ScheduledMeetings)
{
Expand All @@ -8097,43 +8095,6 @@ TEST_F(MegaChatApiTest, ScheduledMeetings)
// aux data structure to handle lambdas' arguments
SchedMeetingData smDataTests1, smDataTests2;

// remove scheduled meeting
const auto deleteSchedMeeting = [this](const unsigned int index, const int expectedError, const SchedMeetingData& smData) -> void
{
bool exitFlag = false;
mSchedMeetingUpdated[a1] = mSchedMeetingUpdated[a2] = false; // reset sched meetings updated flags
mSchedIdRemoved[a1] = mSchedIdRemoved[a2] = MEGACHAT_INVALID_HANDLE; // reset sched meetings id's (do after assign vars above)

// wait for onRequestFinish
ASSERT_NO_FATAL_FAILURE(
waitForAction (1,
std::vector<bool *> { &exitFlag },
std::vector<string> { "TYPE_DELETE_SCHEDULED_MEETING[a1]"},
"Removing scheduled meeting from A",
true /* wait for all exit flags*/,
true /*reset flags*/,
maxTimeout,
[&api = megaChatApi[index], &d = smData, &expectedError, &exitFlag]()
{
ChatRequestTracker crtRemoveMeeting(api);
api->removeScheduledMeeting(d.chatId, d.schedId, &crtRemoveMeeting);
auto res = crtRemoveMeeting.waitForResult();
exitFlag = true;
ASSERT_EQ(res, expectedError)
<< "Unexpected error while removing scheduled meeting. Error: " << crtRemoveMeeting.getErrorString();
});
);
if (expectedError != MegaChatError::ERROR_OK) { return; }

// wait for onChatSchedMeetingUpdate (just in case expectedError is ERROR_OK)
waitForMultiResponse(std::vector<bool *> {&mSchedMeetingUpdated[a1], &mSchedMeetingUpdated[a2]}, true, maxTimeout);
ASSERT_NE(mSchedIdRemoved[a1], MEGACHAT_INVALID_HANDLE) << "Scheduled meeting for primary account could not be removed. scheduled meeting id: "
<< getSchedIdStrB64(smData.schedId);

ASSERT_NE(mSchedIdRemoved[a2], MEGACHAT_INVALID_HANDLE) << "Scheduled meeting for secondary account could not be removed. scheduled meeting id: "
<< getSchedIdStrB64(smData.schedId);
};

// fetch scheduled meeting occurrences
std::unique_ptr<::megachat::MegaChatScheduledMeetingOccurrList> occurrences;
const auto fetchOccurrences = [this, &occurrences](const unsigned int index, const int expectedError,
Expand Down Expand Up @@ -8676,23 +8637,12 @@ TEST_F(MegaChatApiTest, ScheduledMeetings)
}

// check that SC_NEW_SCHED management msg content is expected
ASSERT_NO_FATAL_FAILURE(checkSchedMeetMsg(a2
, chatid
, MEGACHAT_INVALID_HANDLE
, std::vector<unsigned int> { MegaChatScheduledMeeting::SC_CANC }
, "Test10"));

LOG_debug << "#### Test11. A Deletes scheduled meeting with invalid schedId (Error) ####";
smData = SchedMeetingData(); // Designated initializers generate too many warnings (gcc)
smData.chatId = chatid;
smData.schedId = MEGACHAT_INVALID_HANDLE;
ASSERT_NO_FATAL_FAILURE(deleteSchedMeeting(a1, MegaChatError::ERROR_ARGS, smData));

LOG_debug << "#### Test12. A Deletes scheduled meeting ####";
smData = SchedMeetingData(); // Designated initializers generate too many warnings (gcc)
smData.chatId = chatid;
smData.schedId = schedId;
ASSERT_NO_FATAL_FAILURE(deleteSchedMeeting(a1, MegaChatError::ERROR_OK, smData));
ASSERT_NO_FATAL_FAILURE(
checkSchedMeetMsg(a2,
chatid,
MEGACHAT_INVALID_HANDLE,
std::vector<unsigned int>{MegaChatScheduledMeeting::SC_CANC},
"Test10"));
}
#endif

Expand Down

0 comments on commit 0e2c2b1

Please sign in to comment.