31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1 | use std::{future::Future, panic::AssertUnwindSafe}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 2 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 3 | use futures_util::FutureExt; |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 4 | use matrix_sdk::encryption::verification::VerificationRequest; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 5 | use matrix_sdk::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 6 | Client, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 7 | notification_settings::{IsEncrypted, IsOneToOne, RoomNotificationMode as SdkMode}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 8 | ruma::{ |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 9 | OwnedDeviceId, OwnedEventId, OwnedMxcUri, RoomId, TransactionId, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 10 | api::client::{ |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 11 | push::{get_pushrule, set_pushrule_actions}, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 12 | receipt::create_receipt::v3::ReceiptType, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 13 | }, |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 14 | events::receipt::ReceiptThread, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 15 | push::{Action, HighlightTweakValue, RuleKind, Tweak}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 16 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 17 | send_queue::{LocalEchoContent, SendHandle}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 18 | }; |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 19 | use tokio::sync::{mpsc, watch}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 20 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 21 | use crate::{ |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 22 | CommandOutput, EncryptionCommand, Error, ErrorKind, InteractiveAuth, InteractiveAuthChallenge, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 23 | NotificationCommand, RecoveryKey, RoomNotificationMode, TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 24 | encryption::VerificationController, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 25 | transport::{EventSender, Responder}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 26 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 27 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 28 | pub(super) struct Job<T> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 29 | pub(super) command: T, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 30 | pub(super) reply: Responder, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 31 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 32 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 33 | /// a panicking command answers with an error instead of taking its worker down with it |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 34 | pub(super) async fn guarded<T>( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 35 | label: &'static str, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 36 | work: impl Future<Output = Result<T, Error>>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 37 | ) -> Result<T, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 38 | AssertUnwindSafe(work) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 39 | .catch_unwind() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 40 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 41 | .unwrap_or_else(|_| Err(Error::new(ErrorKind::Other, format!("{label} panicked")))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 42 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 43 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 44 | pub(super) async fn run_notifications( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 45 | client: Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 46 | mut jobs: mpsc::Receiver<Job<NotificationCommand>>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 47 | ) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 48 | while let Some(Job { command, reply }) = jobs.recv().await { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 49 | reply.done(guarded("notification command", notification(&client, command)).await); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 50 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 51 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 52 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 53 | pub(super) async fn run_encryption( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 54 | client: Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 55 | events: EventSender, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 56 | mut jobs: mpsc::Receiver<Job<EncryptionCommand>>, |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 57 | mut incoming: mpsc::UnboundedReceiver<VerificationRequest>, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 58 | enabling: watch::Sender<bool>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 59 | ) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 60 | let mut verification = VerificationController::default(); |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 61 | loop { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 62 | tokio::select! { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 63 | job = jobs.recv() => { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 64 | let Some(Job { command, reply }) = job else { return }; |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 65 | let work = encryption(&client, &events, &mut verification, &enabling, command); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 66 | reply.send(guarded("encryption command", work).await); |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 67 | } |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 68 | Some(request) = incoming.recv() => { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 69 | verification.adopt_incoming(events.clone(), request).await; |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 70 | } |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 71 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 72 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 73 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 74 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 75 | async fn encryption( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 76 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 77 | events: &EventSender, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 78 | verification: &mut VerificationController, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 79 | enabling: &watch::Sender<bool>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 80 | command: EncryptionCommand, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 81 | ) -> Result<CommandOutput, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 82 | let encryption = client.encryption(); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 83 | let recovery = encryption.recovery(); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 84 | let key = |key: String| CommandOutput::RecoveryKey(RecoveryKey::new(key)); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 85 | let done = CommandOutput::Done; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 86 | match command { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 87 | EncryptionCommand::EnableRecovery { passphrase } => { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 88 | let _enabling = Enabling::start(enabling); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 89 | let enable = recovery.enable(); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 90 | match passphrase.as_deref() { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 91 | Some(passphrase) => enable.with_passphrase(passphrase).await, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 92 | None => enable.await, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 93 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 94 | .map(key) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 95 | .map_err(|source| Error::from_recovery("enabling recovery failed", source)) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 96 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 97 | EncryptionCommand::ResetRecoveryKey { passphrase } => { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 98 | let reset = recovery.reset_key(); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 99 | match passphrase.as_deref() { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 100 | Some(passphrase) => reset.with_passphrase(passphrase).await, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 101 | None => reset.await, |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 102 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 103 | .map(key) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 104 | .map_err(|source| Error::from_recovery("resetting the recovery key failed", source)) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 105 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 106 | EncryptionCommand::DisableRecovery => recovery |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 107 | .disable() |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 108 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 109 | .map(|()| done) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 110 | .map_err(|source| Error::from_recovery("disabling recovery failed", source)), |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 111 | EncryptionCommand::Recover(key) => recovery |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 112 | .recover(&key) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 113 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 114 | .map(|()| done) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 115 | .map_err(|source| Error::from_recovery("account recovery failed", source)), |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 116 | EncryptionCommand::RecoverKeyBackup(key) => recovery |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 117 | .recover_and_fix_backup(&key) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 118 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 119 | .map(|()| done) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 120 | .map_err(|source| Error::from_recovery("recovering key backup failed", source)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 121 | EncryptionCommand::CreateKeyBackup => encryption |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 122 | .backups() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 123 | .create() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 124 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 125 | .map(|()| done) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 126 | .map_err(|source| Error::from_sdk("creating key backup failed", source)), |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 127 | EncryptionCommand::EnableKeyBackup => recovery |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 128 | .enable_backup() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 129 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 130 | .map(|()| done) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 131 | .map_err(|source| Error::from_recovery("enabling key backup failed", source)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 132 | EncryptionCommand::DisableKeyBackup { delete_from_server } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 133 | let backups = encryption.backups(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 134 | if delete_from_server { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 135 | backups.disable_and_delete().await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 136 | } else { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 137 | backups.disable().await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 138 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 139 | .map(|()| done) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 140 | .map_err(|source| Error::from_sdk("disabling key backup failed", source)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 141 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 142 | EncryptionCommand::StartVerification(target) => verification |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 143 | .start(client, events.clone(), target) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 144 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 145 | .map(|()| done), |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 146 | EncryptionCommand::Verify(action) => verification |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 147 | .apply(events.clone(), action) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 148 | .await |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 149 | .map(|()| done), |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 150 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 151 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 152 | |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 153 | /// a panicking enable must not leave the state saying it is still running |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 154 | struct Enabling<'a>(&'a watch::Sender<bool>); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 155 | |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 156 | impl<'a> Enabling<'a> { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 157 | fn start(sender: &'a watch::Sender<bool>) -> Self { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 158 | sender.send_replace(true); |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 159 | Self(sender) |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 160 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 161 | } |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 162 | |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 163 | impl Drop for Enabling<'_> { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 164 | fn drop(&mut self) { |
743123167e29 | atagen | 2026-10-26 04:02 UTC | 165 | self.0.send_replace(false); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 166 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 167 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 168 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 169 | async fn notification(client: &Client, command: NotificationCommand) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 170 | let settings = client.notification_settings().await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 171 | match command { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 172 | NotificationCommand::SetRoomMode { room_id, mode } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 173 | settings |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 174 | .set_room_notification_mode(&room_id, sdk_mode(mode)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 175 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 176 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 177 | NotificationCommand::ResetRoomMode(room_id) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 178 | settings.delete_user_defined_room_rules(&room_id).await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 179 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 180 | NotificationCommand::SetDefaultMode { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 181 | encrypted, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 182 | one_to_one, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 183 | mode, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 184 | } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 185 | settings |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 186 | .set_default_room_notification_mode( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 187 | IsEncrypted::from(encrypted), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 188 | IsOneToOne::from(one_to_one), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 189 | sdk_mode(mode), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 190 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 191 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 192 | } |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 193 | NotificationCommand::AddKeyword(keyword) => { |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 194 | match settings.add_keyword(keyword.clone()).await { |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 195 | Ok(()) => return highlight_keyword(client, &keyword).await, |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 196 | Err(error) => Err(error), |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 197 | } |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 198 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 199 | NotificationCommand::RemoveKeyword(keyword) => settings.remove_keyword(&keyword).await, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 200 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 201 | .map_err(|source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 202 | Error::with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 203 | ErrorKind::Server, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 204 | "updating notification settings failed", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 205 | source, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 206 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 207 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 208 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 209 | |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 210 | /// sdk keyword rules carry only notify and a sound, while Element's loud keywords also |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 211 | /// highlight, which is what lets the inbox keep them as mentions. The sdk names a |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 212 | /// keyword's content rule after the keyword itself, a rule under another id is left |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 213 | /// alone. |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 214 | async fn highlight_keyword(client: &Client, keyword: &str) -> Result<(), Error> { |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 215 | let failed = |source| Error::from_http("highlighting a notification keyword failed", source); |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 216 | let rule = match client |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 217 | .send(get_pushrule::v3::Request::new( |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 218 | RuleKind::Content, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 219 | keyword.to_owned(), |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 220 | )) |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 221 | .await |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 222 | { |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 223 | Ok(response) => response.rule, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 224 | Err(error) |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 225 | if error |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 226 | .as_client_api_error() |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 227 | .is_some_and(|error| error.status_code.as_u16() == 404) => |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 228 | { |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 229 | return Ok(()); |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 230 | } |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 231 | Err(error) => return Err(failed(error)), |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 232 | }; |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 233 | if rule.actions.iter().any(Action::is_highlight) { |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 234 | return Ok(()); |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 235 | } |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 236 | let mut actions: Vec<_> = rule |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 237 | .actions |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 238 | .into_iter() |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 239 | .filter(|action| !matches!(action, Action::SetTweak(Tweak::Highlight(_)))) |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 240 | .collect(); |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 241 | actions.push(Action::SetTweak(Tweak::Highlight(HighlightTweakValue::Yes))); |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 242 | client |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 243 | .send(set_pushrule_actions::v3::Request::new( |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 244 | RuleKind::Content, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 245 | keyword.to_owned(), |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 246 | actions, |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 247 | )) |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 248 | .await |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 249 | .map_err(failed)?; |
e9af9e0e0f31 | atagen | 2026-10-25 10:55 UTC | 250 | Ok(()) |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 251 | } |
5b585cd970fd | atagen | 2026-10-25 09:20 UTC | 252 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 253 | const fn sdk_mode(mode: RoomNotificationMode) -> SdkMode { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 254 | match mode { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 255 | RoomNotificationMode::AllMessages => SdkMode::AllMessages, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 256 | RoomNotificationMode::MentionsAndKeywordsOnly => SdkMode::MentionsAndKeywordsOnly, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 257 | RoomNotificationMode::Mute => SdkMode::Mute, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 258 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 259 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 260 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 261 | fn room(client: &Client, room_id: &RoomId) -> Result<matrix_sdk::Room, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 262 | client.get_room(room_id).ok_or_else(Error::room_unknown) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 263 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 264 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 265 | /// the closed-room path. without a timeline nothing stops the marker going backwards |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 266 | pub(super) async fn mark_read( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 267 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 268 | timeline_id: &TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 269 | event_id: OwnedEventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 270 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 271 | let room = room(client, timeline_id.room_id())?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 272 | let receipt_failed = |source| Error::from_sdk("sending read receipt failed", source); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 273 | let thread = match timeline_id.thread_root() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 274 | None => ReceiptThread::Main, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 275 | Some(root) => ReceiptThread::Thread(root.clone()), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 276 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 277 | room.send_single_receipt(ReceiptType::Read, thread, event_id.clone()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 278 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 279 | .map_err(receipt_failed)?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 280 | if timeline_id.thread_root().is_none() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 281 | room.send_single_receipt(ReceiptType::FullyRead, ReceiptThread::Unthreaded, event_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 282 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 283 | .map_err(receipt_failed)?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 284 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 285 | Ok(()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 286 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 287 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 288 | pub(super) async fn set_typing( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 289 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 290 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 291 | typing: bool, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 292 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 293 | room(client, room_id)? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 294 | .typing_notice(typing) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 295 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 296 | .map_err(|source| Error::from_sdk("typing update failed", source)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 297 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 298 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 299 | async fn send_handle( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 300 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 301 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 302 | transaction_id: &TransactionId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 303 | ) -> Result<SendHandle, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 304 | let (echoes, _) = room(client, room_id)? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 305 | .send_queue() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 306 | .subscribe() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 307 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 308 | .map_err(|source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 309 | Error::with_source(ErrorKind::Store, "reading send queue failed", source) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 310 | })?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 311 | echoes |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 312 | .into_iter() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 313 | .find_map(|echo| match echo.content { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 314 | LocalEchoContent::Event { send_handle, .. } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 315 | if echo.transaction_id.as_str() == transaction_id.as_str() => |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 316 | { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 317 | Some(send_handle) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 318 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 319 | _ => None, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 320 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 321 | .ok_or_else(|| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 322 | Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 323 | ErrorKind::Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 324 | "send is no longer pending or is not a message", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 325 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 326 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 327 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 328 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 329 | pub(super) async fn cancel_send( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 330 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 331 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 332 | transaction_id: &TransactionId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 333 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 334 | match send_handle(client, room_id, transaction_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 335 | .await? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 336 | .abort() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 337 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 338 | { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 339 | Ok(true) => Ok(()), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 340 | Ok(false) => Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 341 | ErrorKind::Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 342 | "send could not be cancelled because it has already been sent", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 343 | )), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 344 | Err(source) => Err(Error::with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 345 | ErrorKind::Store, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 346 | "cancelling send failed", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 347 | source, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 348 | )), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 349 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 350 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 351 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 352 | pub(super) async fn retry_send( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 353 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 354 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 355 | transaction_id: &TransactionId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 356 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 357 | send_handle(client, room_id, transaction_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 358 | .await? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 359 | .unwedge() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 360 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 361 | .map_err(|source| Error::with_source(ErrorKind::Store, "retrying send failed", source))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 362 | room(client, room_id)?.send_queue().set_enabled(true); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 363 | Ok(()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 364 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 365 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 366 | pub(super) async fn upload_avatar( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 367 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 368 | mimetype: &str, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 369 | bytes: Vec<u8>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 370 | max_bytes: usize, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 371 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 372 | if bytes.len() > max_bytes { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 373 | return Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 374 | ErrorKind::MediaTooLarge, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 375 | "avatar exceeds the configured byte limit", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 376 | )); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 377 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 378 | let mimetype: mime::Mime = mimetype |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 379 | .parse() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 380 | .map_err(|_| Error::new(ErrorKind::Invalid, "avatar MIME type is invalid"))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 381 | if mimetype.type_() != mime::IMAGE { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 382 | return Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 383 | ErrorKind::Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 384 | "an avatar has to be an image", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 385 | )); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 386 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 387 | client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 388 | .account() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 389 | .upload_avatar(&mimetype, bytes) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 390 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 391 | .map(drop) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 392 | .map_err(|source| Error::from_sdk("uploading avatar failed", source)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 393 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 394 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 395 | pub(super) async fn upload_media( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 396 | client: &Client, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 397 | mimetype: &str, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 398 | bytes: Vec<u8>, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 399 | max_bytes: usize, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 400 | ) -> Result<OwnedMxcUri, Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 401 | if bytes.len() > max_bytes { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 402 | return Err(Error::new( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 403 | ErrorKind::MediaTooLarge, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 404 | "media exceeds the configured byte limit", |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 405 | )); |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 406 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 407 | let mimetype: mime::Mime = mimetype |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 408 | .parse() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 409 | .map_err(|_| Error::new(ErrorKind::Invalid, "media MIME type is invalid"))?; |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 410 | client |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 411 | .media() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 412 | .upload(&mimetype, bytes, None) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 413 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 414 | .map(|response| response.content_uri) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 415 | .map_err(|source| Error::from_sdk("uploading media failed", source)) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 416 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 417 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 418 | pub(super) async fn rename_device( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 419 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 420 | device_id: &OwnedDeviceId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 421 | display_name: &str, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 422 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 423 | client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 424 | .rename_device(device_id, display_name) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 425 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 426 | .map(drop) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 427 | .map_err(|source| Error::from_http("renaming device failed", source)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 428 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 429 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 430 | pub(super) async fn delete_devices( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 431 | client: &Client, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 432 | device_ids: &[OwnedDeviceId], |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 433 | auth: Option<InteractiveAuth>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 434 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 435 | let user_id = client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 436 | .user_id() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 437 | .ok_or_else(|| Error::new(ErrorKind::Unauthenticated, "the client is not logged in"))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 438 | let auth = auth |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 439 | .map(|auth| auth.into_sdk(user_id)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 440 | .transpose() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 441 | .map_err(|message| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 442 | Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 443 | ErrorKind::Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 444 | format!("interactive authentication data is invalid, {message}"), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 445 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 446 | })?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 447 | match client.delete_devices(device_ids, auth).await { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 448 | Ok(_) => Ok(()), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 449 | Err(source) => match source.as_uiaa_response() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 450 | Some(info) => Err(Error::interactive_auth(InteractiveAuthChallenge::from( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 451 | info, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 452 | ))), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 453 | None => Err(Error::from_http("deleting devices failed", source)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 454 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 455 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 456 | } |