diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2024-06-04 00:37:23 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2024-06-04 00:37:23 +0200 |
commit | d0d95df89d4b5a19d922a4d58b887c583dd9718d (patch) | |
tree | e157d07ce8cb9e255b165a34dfaaf6dfc767d87e /src | |
parent | Prevent opening empty profiles (diff) | |
download | nheko-d0d95df89d4b5a19d922a4d58b887c583dd9718d.tar.xz |
Fix marking newly created rooms as DM automatically
fixes #1718
Diffstat (limited to 'src')
-rw-r--r-- | src/ChatPage.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index be05f8bd..3c663b94 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -986,8 +986,15 @@ ChatPage::createRoom(const mtx::requests::CreateRoom &req) return; } + bool direct = req.is_direct; + std::string direct_user; + if (direct && !req.invite.empty()) + direct_user = req.invite.front(); + http::client()->create_room( - req, [this](const mtx::responses::CreateRoom &res, mtx::http::RequestErr err) { + req, + [this, direct, direct_user](const mtx::responses::CreateRoom &res, + mtx::http::RequestErr err) { if (err) { const auto err_code = mtx::errors::to_string(err->matrix_error.errcode); const auto error = err->matrix_error.error; @@ -1000,6 +1007,16 @@ ChatPage::createRoom(const mtx::requests::CreateRoom &req) } QString newRoomId = QString::fromStdString(res.room_id.to_string()); + + if (direct && !direct_user.empty()) { + utils::markRoomAsDirect(newRoomId, + {RoomMember{ + .user_id = QString::fromStdString(direct_user), + .display_name = "", + .avatar_url = "", + }}); + } + emit showNotification(tr("Room %1 created.").arg(newRoomId)); emit newRoom(newRoomId); emit changeToRoom(newRoomId); |