summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2023-08-10 08:19:32 +0000
committerGitHub <noreply@github.com>2023-08-10 08:19:32 +0000
commit70ede75aa595cef4277a00db01331ed7a4eec130 (patch)
tree185a2c4df9587ad5e1270f887562e4ffa5a23a22 /src
parentMerge pull request #1523 from Nheko-Reborn/qmlFallbackAuth (diff)
parentSwap PL indicator location (diff)
downloadnheko-70ede75aa595cef4277a00db01331ed7a4eec130.tar.xz
Merge pull request #1535 from Nheko-Reborn/powerlevelsInTimeline
Show an indicator in the timeline for mods and admins
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineModel.cpp9
-rw-r--r--src/timeline/TimelineModel.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index fddd5700..b2a036c5 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -535,6 +535,7 @@ TimelineModel::roleNames() const
       {IsSender, "isSender"},
       {UserId, "userId"},
       {UserName, "userName"},
+      {UserPowerlevel, "userPowerlevel"},
       {Day, "day"},
       {Timestamp, "timestamp"},
       {Url, "url"},
@@ -597,6 +598,14 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
         return QVariant(QString::fromStdString(acc::sender(event)));
     case UserName:
         return QVariant(displayName(QString::fromStdString(acc::sender(event))));
+    case UserPowerlevel: {
+        return static_cast<qlonglong>(mtx::events::state::PowerLevels{
+          cache::client()
+            ->getStateEvent<mtx::events::state::PowerLevels>(room_id_.toStdString())
+            .value_or(mtx::events::StateEvent<mtx::events::state::PowerLevels>{})
+            .content}
+                                        .user_level(acc::sender(event)));
+    }
 
     case Day: {
         QDateTime prevDate = origin_server_ts(event);
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 64941920..fccc99eb 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -241,6 +241,7 @@ public:
         IsSender,
         UserId,
         UserName,
+        UserPowerlevel,
         Day,
         Timestamp,
         Url,