sdk: Add a Rules utility struct to manipulate a Ruleset

This commit is contained in:
Nicolas Mauri
2023-06-20 14:56:33 +02:00
committed by GitHub
parent a496471cf3
commit 3f3fd58770
4 changed files with 1131 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -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;

View 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,
}

View File

File diff suppressed because it is too large Load Diff