diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-06-10 00:49:49 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-06-10 00:54:08 +0200 |
commit | 0dbc9444c3d43202db2db90e9bfae54811119a0c (patch) | |
tree | 429e012d41ab536974023285077d0c3c427c39fe /src/timeline | |
parent | Properly set pack avatar (diff) | |
download | nheko-0dbc9444c3d43202db2db90e9bfae54811119a0c.tar.xz |
Add inviter to the invite reason
fixes #622
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/RoomlistModel.cpp | 46 | ||||
-rw-r--r-- | src/timeline/RoomlistModel.h | 6 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index 35507cbd..ec41cc12 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -1235,3 +1235,49 @@ FilteredRoomlistModel::previousRoom() } } } + +QString +RoomPreview::inviterAvatarUrl() const +{ + if (isInvite_) { + auto self = cache::client()->getInviteMember(roomid_.toStdString(), + http::client()->user_id().to_string()); + if (self && !self->inviter.empty()) { + auto other = cache::client()->getInviteMember(roomid_.toStdString(), self->inviter); + if (other && other->avatar_url.starts_with("mxc://")) { + return QString::fromStdString(other->avatar_url); + } + } + } + + return QString(); +} +QString +RoomPreview::inviterDisplayName() const +{ + if (isInvite_) { + auto self = cache::client()->getInviteMember(roomid_.toStdString(), + http::client()->user_id().to_string()); + if (self && !self->inviter.empty()) { + auto other = cache::client()->getInviteMember(roomid_.toStdString(), self->inviter); + if (other) { + return QString::fromStdString(other->name).toHtmlEscaped(); + } + } + } + + return QString(); +} +QString +RoomPreview::inviterUserId() const +{ + if (isInvite_) { + auto self = cache::client()->getInviteMember(roomid_.toStdString(), + http::client()->user_id().to_string()); + if (self && !self->inviter.empty()) { + return QString::fromStdString(self->inviter); + } + } + + return QString(); +} diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index 9aaafc06..c06ab67d 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -31,6 +31,9 @@ class RoomPreview Q_PROPERTY(QString roomTopic READ roomTopic CONSTANT) Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl CONSTANT) Q_PROPERTY(QString reason READ reason CONSTANT) + Q_PROPERTY(QString inviterAvatarUrl READ inviterAvatarUrl CONSTANT) + Q_PROPERTY(QString inviterDisplayName READ inviterDisplayName CONSTANT) + Q_PROPERTY(QString inviterUserId READ inviterUserId CONSTANT) Q_PROPERTY(bool isInvite READ isInvite CONSTANT) Q_PROPERTY(bool isFetched READ isFetched CONSTANT) @@ -42,6 +45,9 @@ public: QString roomTopic() const { return roomTopic_; } QString roomAvatarUrl() const { return roomAvatarUrl_; } QString reason() const { return reason_; } + QString inviterAvatarUrl() const; + QString inviterDisplayName() const; + QString inviterUserId() const; bool isInvite() const { return isInvite_; } bool isFetched() const { return isFetched_; } |