mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Properly figure out entity that is controlled by policy rule
This commit is contained in:
parent
1f971ae940
commit
761e90891f
3 changed files with 38 additions and 3 deletions
|
@ -581,7 +581,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
GIT_TAG c2824dae5050882872a6c3f5677f3309a60511be
|
GIT_TAG 1f42cb0c8560a92b2640306b32cb6a330c564a31
|
||||||
)
|
)
|
||||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -203,7 +203,7 @@ modules:
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
name: mtxclient
|
name: mtxclient
|
||||||
sources:
|
sources:
|
||||||
- commit: c2824dae5050882872a6c3f5677f3309a60511be
|
- commit: 1f42cb0c8560a92b2640306b32cb6a330c564a31
|
||||||
#tag: v0.7.0
|
#tag: v0.7.0
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
|
|
|
@ -2340,7 +2340,8 @@ TimelineModel::formatImagePackEvent(const QString &id)
|
||||||
QString
|
QString
|
||||||
TimelineModel::formatPolicyRule(const QString &id)
|
TimelineModel::formatPolicyRule(const QString &id)
|
||||||
{
|
{
|
||||||
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
|
auto idStr = id.toStdString();
|
||||||
|
mtx::events::collections::TimelineEvents *e = events.get(idStr, "");
|
||||||
if (!e)
|
if (!e)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -2354,6 +2355,18 @@ TimelineModel::formatPolicyRule(const QString &id)
|
||||||
(userRule->content.recommendation !=
|
(userRule->content.recommendation !=
|
||||||
mtx::events::state::policy_rule::recommendation::ban &&
|
mtx::events::state::policy_rule::recommendation::ban &&
|
||||||
userRule->content.recommendation != unstable_ban)) {
|
userRule->content.recommendation != unstable_ban)) {
|
||||||
|
while (userRule->content.entity.empty() &&
|
||||||
|
!userRule->unsigned_data.replaces_state.empty()) {
|
||||||
|
auto temp = events.get(userRule->unsigned_data.replaces_state, idStr);
|
||||||
|
if (!temp)
|
||||||
|
break;
|
||||||
|
if (auto tempRule = std::get_if<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::policy_rule::UserRule>>(temp))
|
||||||
|
userRule = tempRule;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return tr("%1 disabled the rule to ban users matching %2.")
|
return tr("%1 disabled the rule to ban users matching %2.")
|
||||||
.arg(sender, qsHtml(userRule->content.entity));
|
.arg(sender, qsHtml(userRule->content.entity));
|
||||||
} else {
|
} else {
|
||||||
|
@ -2368,6 +2381,17 @@ TimelineModel::formatPolicyRule(const QString &id)
|
||||||
(roomRule->content.recommendation !=
|
(roomRule->content.recommendation !=
|
||||||
mtx::events::state::policy_rule::recommendation::ban &&
|
mtx::events::state::policy_rule::recommendation::ban &&
|
||||||
roomRule->content.recommendation != unstable_ban)) {
|
roomRule->content.recommendation != unstable_ban)) {
|
||||||
|
while (roomRule->content.entity.empty() &&
|
||||||
|
!roomRule->unsigned_data.replaces_state.empty()) {
|
||||||
|
auto temp = events.get(roomRule->unsigned_data.replaces_state, idStr);
|
||||||
|
if (!temp)
|
||||||
|
break;
|
||||||
|
if (auto tempRule = std::get_if<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::policy_rule::RoomRule>>(temp))
|
||||||
|
roomRule = tempRule;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
return tr("%1 disabled the rule to ban rooms matching %2.")
|
return tr("%1 disabled the rule to ban rooms matching %2.")
|
||||||
.arg(sender, qsHtml(roomRule->content.entity));
|
.arg(sender, qsHtml(roomRule->content.entity));
|
||||||
} else {
|
} else {
|
||||||
|
@ -2382,6 +2406,17 @@ TimelineModel::formatPolicyRule(const QString &id)
|
||||||
(serverRule->content.recommendation !=
|
(serverRule->content.recommendation !=
|
||||||
mtx::events::state::policy_rule::recommendation::ban &&
|
mtx::events::state::policy_rule::recommendation::ban &&
|
||||||
serverRule->content.recommendation != unstable_ban)) {
|
serverRule->content.recommendation != unstable_ban)) {
|
||||||
|
while (serverRule->content.entity.empty() &&
|
||||||
|
!serverRule->unsigned_data.replaces_state.empty()) {
|
||||||
|
auto temp = events.get(serverRule->unsigned_data.replaces_state, idStr);
|
||||||
|
if (!temp)
|
||||||
|
break;
|
||||||
|
if (auto tempRule = std::get_if<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::policy_rule::ServerRule>>(temp))
|
||||||
|
serverRule = tempRule;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
return tr("%1 disabled the rule to ban servers matching %2.")
|
return tr("%1 disabled the rule to ban servers matching %2.")
|
||||||
.arg(sender, qsHtml(serverRule->content.entity));
|
.arg(sender, qsHtml(serverRule->content.entity));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue