diff options
author | Jedi18 <targetakhil@gmail.com> | 2021-01-27 11:03:08 +0530 |
---|---|---|
committer | Jedi18 <targetakhil@gmail.com> | 2021-01-27 11:03:08 +0530 |
commit | 5e3f5136557b83ee964d6c0cfa4fed422330728d (patch) | |
tree | 1b94d5d41571f83ffbaecff2a8dffda42ccc0b91 /src/ui/UserProfile.cpp | |
parent | e6dc1da22f32fe8c7cd9fe0c56cfdfa869556a0c (diff) |
update room specific username from userprofile
Diffstat (limited to 'src/ui/UserProfile.cpp')
-rw-r--r-- | src/ui/UserProfile.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index 08219a38..503f314c 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -4,6 +4,7 @@ #include "DeviceVerificationFlow.h" #include "Logging.h" #include "Utils.h" +#include <mtx/responses/common.hpp> #include "mtx/responses/crypto.hpp" #include "timeline/TimelineModel.h" #include "timeline/TimelineViewManager.h" @@ -214,6 +215,44 @@ UserProfile::startChat() } void +UserProfile::changeUsername(QString username) +{ + // change room username + mtx::events::state::Member member; + member.display_name = username.toStdString(); + member.avatar_url = + cache::avatarUrl(roomid_, + QString::fromStdString(http::client()->user_id().to_string())) + .toStdString(); + member.membership = mtx::events::state::Membership::Join; + + http::client()->send_state_event(roomid_.toStdString(), + http::client()->user_id().to_string(), + member, + [](mtx::responses::EventId, mtx::http::RequestErr err) { + if (err) + nhlog::net()->error( + "Failed to set room displayname: {}", + err->matrix_error.error); + }); + + /*connect(modal, &EditModal::nameChanged, this, [this](const QString &newName) { + if (roomNameLabel_) + roomNameLabel_->setText(newName); + });*/ + + /*std::string newName = "jedi18"; + // change user name + http::client()->set_displayname( + newName, [this]( mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn("could not change username"); + return; + } + });*/ +} + +void UserProfile::verify(QString device) { if (!device.isEmpty()) |