aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-16 17:29:15 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-16 17:29:15 +0900
commit4e2de22c7d327836d2fe44764f8c7855a51f6206 (patch)
tree48325ce411d994efc125624660665b48d37beaa1
parent11b1bfe8f3640bfb1e2dd1710624c67aedb4f98b (diff)
downloadlibquotient-4e2de22c7d327836d2fe44764f8c7855a51f6206.tar.gz
libquotient-4e2de22c7d327836d2fe44764f8c7855a51f6206.zip
Room::checkVersion(): check power levels
This is a flimsy implementation without proper RoomPowerLevelEvent definition, just to enable upgrades without causing noise to each and every user of a room on an unstable version.
-rw-r--r--lib/room.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index aa835860..3a37053d 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1622,9 +1622,25 @@ void Room::checkVersion()
{
qCDebug(MAIN) << this << "version is" << version()
<< "which the server doesn't count as stable";
- // TODO: m.room.power_levels
- qCDebug(MAIN) << "The current user has enough privileges to fix it";
- emit unstableVersion(defaultVersion, stableVersions);
+ // TODO, #276: m.room.power_levels
+ if (const auto* plEvt =
+ d->currentState.value({"m.room.power_levels", ""}))
+ {
+ const auto plJson = plEvt->contentJson();
+ const auto currentUserLevel =
+ plJson.value("users"_ls).toObject()
+ .value(localUser()->id()).toInt(
+ plJson.value("users_default"_ls).toInt());
+ const auto tombstonePowerLevel =
+ plJson.value("events").toObject()
+ .value("m.room.tombstone"_ls).toInt(
+ plJson.value("state_default"_ls).toInt());
+ if (currentUserLevel >= tombstonePowerLevel)
+ {
+ qCDebug(MAIN) << "The current user has enough privileges to fix it";
+ emit unstableVersion(defaultVersion, stableVersions);
+ }
+ }
}
}