summary refs log tree commit diff
path: root/src/ChatPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-05-18 14:02:14 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2020-05-18 14:02:14 +0200
commit23e4408fa8a840b78984c97aa927a120a465fd12 (patch)
tree9ee54fe4fe5853e8ee8c8aa0e531142e04eec308 /src/ChatPage.cpp
parentTag rooms via context menu (diff)
downloadnheko-23e4408fa8a840b78984c97aa927a120a465fd12.tar.xz
Add /roomnick command
Diffstat (limited to 'src/ChatPage.cpp')
-rw-r--r--src/ChatPage.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index d0ca4670..90abc63e 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -301,6 +301,29 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
         connect(text_input_, &TextInputWidget::sendUnbanRoomRequest, this, &ChatPage::unbanUser);
 
         connect(
+          text_input_, &TextInputWidget::changeRoomNick, this, [this](const QString &displayName) {
+                  mtx::events::state::Member member;
+                  member.display_name = displayName.toStdString();
+                  member.avatar_url =
+                    cache::avatarUrl(currentRoom(),
+                                     QString::fromStdString(http::client()->user_id().to_string()))
+                      .toStdString();
+                  member.membership = mtx::events::state::Membership::Join;
+
+                  http::client()
+                    ->send_state_event<mtx::events::state::Member,
+                                       mtx::events::EventType::RoomMember>(
+                      currentRoom().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(
           text_input_,
           &TextInputWidget::uploadMedia,
           this,