Initial work to add push rule support

This commit adds the ability to set the master push rule and set push rules for individual rooms as per the matrix spec. See https://spec.matrix.org/v1.3/client-server-api/#push-rules.

The master push rule is just on/off and uses the existing notification setting in general setting to enable/disable the server default master push rule .m.rule.master.

For each room there is now a page in the room setting that allows the following to be set:
- Default
- All messages
- @mentions and keywords
- off

New room or override rules are added/removed to achieve this.

There is also functionality to check the master/room notification state whenever the setting menu is entered. This allows the status to be updated if changed in another client or get the initial state for a room as it isn't stored.

Note - There is currently no menu items in the room list for setting the room push rule settings. This will be added in a later commit, the aim is to focus on making sure the technical implementation is good for now.
This commit is contained in:
James Graham
2022-09-09 16:41:03 +00:00
parent c2fc4e44a7
commit 4bba505da6
11 changed files with 353 additions and 5 deletions

View File

@@ -10,11 +10,13 @@
#include <KNotification>
#include "neochatconfig.h"
#include "neochatroom.h"
class NotificationsManager : public QObject
{
Q_OBJECT
Q_PROPERTY(bool globalNotificationsEnabled MEMBER m_globalNotificationsEnabled WRITE setGlobalNotificationsEnabled NOTIFY globalNotificationsEnabledChanged)
public:
static NotificationsManager &instance();
@@ -25,9 +27,19 @@ public:
void clearInvitationNotification(const QString &roomId);
Q_INVOKABLE void setGlobalNotificationsEnabled(bool enabled);
private:
NotificationsManager(QObject *parent = nullptr);
QMultiMap<QString, KNotification *> m_notifications;
QHash<QString, QPointer<KNotification>> m_invitations;
bool m_globalNotificationsEnabled;
private Q_SLOTS:
void updateGlobalNotificationsEnabled(QString type);
Q_SIGNALS:
void globalNotificationsEnabledChanged(bool newState);
};