mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 06:04:31 -04:00
sdk: Add a Rules utility struct to manipulate a Ruleset
This commit is contained in:
@@ -30,6 +30,7 @@ use ruma::{
|
||||
error::{FromHttpResponseError, IntoHttpError},
|
||||
},
|
||||
events::tag::InvalidUserTagName,
|
||||
push::{InsertPushRuleError, RuleNotFoundError},
|
||||
IdParseError,
|
||||
};
|
||||
use serde_json::Error as JsonError;
|
||||
@@ -422,3 +423,29 @@ pub enum RefreshTokenError {
|
||||
#[error("the access token could not be refreshed")]
|
||||
UnableToRefreshToken,
|
||||
}
|
||||
|
||||
/// Errors that can occur when manipulating push notification settings.
|
||||
#[derive(Debug, Error, Clone, PartialEq)]
|
||||
pub enum NotificationSettingsError {
|
||||
/// Invalid parameter.
|
||||
#[error("Invalid parameter `{0}`")]
|
||||
InvalidParameter(String),
|
||||
/// Rule not found
|
||||
#[error("Rule not found")]
|
||||
RuleNotFound,
|
||||
/// Unable to add push rule.
|
||||
#[error("Unable to add push rule")]
|
||||
UnableToAddPushRule,
|
||||
}
|
||||
|
||||
impl From<InsertPushRuleError> for NotificationSettingsError {
|
||||
fn from(_: InsertPushRuleError) -> Self {
|
||||
Self::UnableToAddPushRule
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RuleNotFoundError> for NotificationSettingsError {
|
||||
fn from(_: RuleNotFoundError) -> Self {
|
||||
Self::RuleNotFound
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ mod error;
|
||||
pub mod event_handler;
|
||||
mod http_client;
|
||||
pub mod media;
|
||||
pub mod notification_settings;
|
||||
pub mod room;
|
||||
pub mod sync;
|
||||
|
||||
|
||||
14
crates/matrix-sdk/src/notification_settings/mod.rs
Normal file
14
crates/matrix-sdk/src/notification_settings/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
//! High-level push notification settings API
|
||||
|
||||
mod rules;
|
||||
|
||||
/// Enum representing the push notification modes for a room.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum RoomNotificationMode {
|
||||
/// Receive notifications for all messages.
|
||||
AllMessages,
|
||||
/// Receive notifications for mentions and keywords only.
|
||||
MentionsAndKeywordsOnly,
|
||||
/// Do not receive any notifications.
|
||||
Mute,
|
||||
}
|
||||
1089
crates/matrix-sdk/src/notification_settings/rules.rs
Normal file
1089
crates/matrix-sdk/src/notification_settings/rules.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user