mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
parent
9f5982e180
commit
d0d95df89d
1 changed files with 18 additions and 1 deletions
|
@ -986,8 +986,15 @@ ChatPage::createRoom(const mtx::requests::CreateRoom &req)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool direct = req.is_direct;
|
||||||
|
std::string direct_user;
|
||||||
|
if (direct && !req.invite.empty())
|
||||||
|
direct_user = req.invite.front();
|
||||||
|
|
||||||
http::client()->create_room(
|
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) {
|
if (err) {
|
||||||
const auto err_code = mtx::errors::to_string(err->matrix_error.errcode);
|
const auto err_code = mtx::errors::to_string(err->matrix_error.errcode);
|
||||||
const auto error = err->matrix_error.error;
|
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());
|
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 showNotification(tr("Room %1 created.").arg(newRoomId));
|
||||||
emit newRoom(newRoomId);
|
emit newRoom(newRoomId);
|
||||||
emit changeToRoom(newRoomId);
|
emit changeToRoom(newRoomId);
|
||||||
|
|
Loading…
Reference in a new issue