New default pushrules

Add handling for new default push rules added in 1.7 also add a generic unknown handling for if any others are added in the future so they don't appear in keywords
This commit is contained in:
James Graham
2023-09-02 15:48:50 +00:00
parent 5871903529
commit ede2707767
3 changed files with 39 additions and 0 deletions

View File

@@ -23,6 +23,9 @@ static const QHash<QString, QString> defaultRuleNames = {
{QStringLiteral(".m.rule.encrypted"), QStringLiteral("Messages in encrypted group chats")},
{QStringLiteral(".m.rule.tombstone"), QStringLiteral("Room upgrade messages")},
{QStringLiteral(".m.rule.contains_display_name"), QStringLiteral("Messages containing my display name")},
{QStringLiteral(".m.rule.is_user_mention"), QStringLiteral("Messages which mention my Matrix user ID.")},
{QStringLiteral(".m.rule.is_room_mention"), QStringLiteral("Messages which mention a room.")},
{QStringLiteral(".m.rule.contains_user_name"), QStringLiteral("Messages containing the local part of my Matrix ID.")},
{QStringLiteral(".m.rule.roomnotif"), QStringLiteral("Whole room (@room) notifications")},
{QStringLiteral(".m.rule.invite_for_me"), QStringLiteral("Invites to a room")},
{QStringLiteral(".m.rule.call"), QStringLiteral("Call invitation")},
@@ -37,6 +40,9 @@ static const QHash<QString, PushNotificationSection::Section> defaultSections =
{QStringLiteral(".m.rule.encrypted"), PushNotificationSection::Room},
{QStringLiteral(".m.rule.tombstone"), PushNotificationSection::Room},
{QStringLiteral(".m.rule.contains_display_name"), PushNotificationSection::Mentions},
{QStringLiteral(".m.rule.is_user_mention"), PushNotificationSection::Mentions},
{QStringLiteral(".m.rule.is_room_mention"), PushNotificationSection::Mentions},
{QStringLiteral(".m.rule.contains_user_name"), PushNotificationSection::Mentions},
{QStringLiteral(".m.rule.roomnotif"), PushNotificationSection::Mentions},
{QStringLiteral(".m.rule.invite_for_me"), PushNotificationSection::Invites},
{QStringLiteral(".m.rule.call"), PushNotificationSection::Undefined}, // TODO: make invites when VOIP added.
@@ -140,6 +146,9 @@ PushNotificationSection::Section PushRuleModel::getSection(Quotient::PushRule ru
if (defaultSections.contains(ruleId)) {
return defaultSections.value(ruleId);
} else {
if (rule.ruleId.startsWith(u'.')) {
return PushNotificationSection::Unknown;
}
/**
* If the rule name resolves to a matrix id for a room that the user is part
* of it shouldn't appear in the global list as it's overriding the global

View File

@@ -83,12 +83,16 @@ public:
Keywords, /**< Global Keyword push rules. */
RoomKeywords, /**< Keyword push rules that only apply to a specific room. */
Invites, /**< Push rules relating to invites. */
Unknown, /**< New default push rules that have not been added to the model yet. */
/**
* @brief Push rules that should never be shown.
*
* There are numerous rules that get set that shouldn't be shown in the general
* list e.g. The array of rules used to override global settings in individual
* rooms.
*
* This is specifically different to unknown which are just new default push
* rule that haven't been added to the model yet.
*/
Undefined,
};

View File

@@ -176,6 +176,32 @@ Kirigami.ScrollablePage {
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
title: i18n("Unknown")
visible: unknownModel.rowCount() > 0
}
MobileForm.FormCard {
Layout.fillWidth: true
visible: unknownModel.rowCount() > 0
contentItem: ColumnLayout {
spacing: 0
Repeater {
model: KSortFilterProxyModel {
id: unknownModel
sourceModel: Controller.pushRuleModel
filterRowCallback: function(source_row, source_parent) {
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
return sectionRole == PushNotificationSection.Unknown;
}
}
delegate: ruleDelegate
}
}
}
}
Component {