96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1 | use std::{ |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 2 | collections::HashSet, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 3 | fmt, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 4 | future::Future, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 5 | pin::Pin, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 6 | sync::{Arc, Mutex}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 7 | task::{Context, Poll}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 8 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 9 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 10 | use matrix_sdk::{Client, RoomMemberships}; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 11 | use matrix_sdk_ui::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 12 | notification_client::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 13 | NotificationClient, NotificationProcessSetup, NotificationStatus, RawNotificationEvent, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 14 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 15 | spaces::{SpaceRoomList, SpaceService, room_list::SpaceRoomListPaginationState}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 16 | sync_service::SyncService, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 17 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 18 | use ruma::{ |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 19 | EventId, OwnedDeviceId, OwnedEventId, OwnedMxcUri, OwnedRoomId, OwnedRoomOrAliasId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 20 | OwnedServerName, OwnedTransactionId, OwnedUserId, RoomId, UserId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 21 | events::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 22 | AnyGlobalAccountDataEventContent, AnyRoomAccountDataEvent, AnyRoomAccountDataEventContent, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 23 | GlobalAccountDataEventType, RoomAccountDataEventType, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 24 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 25 | serde::Raw, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 26 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 27 | use tokio::sync::{OnceCell, mpsc, oneshot, watch}; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 28 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 29 | use crate::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 30 | AccountCommand, AttachmentUpload, Command, CommandOutput, ConnectionState, CreateRoomOptions, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 31 | EncryptionCommand, EncryptionState, Error, ErrorKind, Event, EventRef, ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 32 | ImagePacks, InteractiveAuth, InteractiveAuthOutcome, LifecycleCommand, LinkPreview, Media, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 33 | MediaCommand, MediaId, MediaLocation, MediaSize, MemberFilter, MemberSummary, MessageContent, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 34 | MessageEditContent, NotificationCommand, OwnDevice, PackCommand, PackImageInfo, PackUsage, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 35 | Patch, PowerLevelChanges, Profile, PushNotification, PushNotificationEvent, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 36 | PushNotificationStatus, RoomCommand, RoomListFilter, RoomNotificationMode, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 37 | RoomNotificationSettings, RoomPowerLevels, RoomSummary, SpaceChild, TimelineCommand, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 38 | TimelineId, VerificationAction, VerificationTarget, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 39 | encryption::encryption_state, |
a250c7fa43fb | atagen | 2026-09-26 13:35 UTC | 40 | engine::{MediaService, StoreLock}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 41 | model::{PushNotificationRoom, PushNotificationSender}, |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 42 | normalise::{image_packs, member_summary, room_summaries, space_child, url_previews_allowed}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 43 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 44 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 45 | #[derive(Clone)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 46 | pub struct ClientHandle { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 47 | requests: mpsc::Sender<Request>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 48 | client: Client, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 49 | connection: watch::Receiver<ConnectionState>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 50 | notification_client: Arc<OnceCell<NotificationClient>>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 51 | sync_service: Arc<SyncService>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 52 | media: Arc<MediaService>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 53 | spaces: Arc<OnceCell<SpaceService>>, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 54 | members_checked: Arc<Mutex<HashSet<OwnedRoomId>>>, |
a250c7fa43fb | atagen | 2026-09-26 13:35 UTC | 55 | _store_lock: Option<Arc<StoreLock>>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 56 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 57 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 58 | impl fmt::Debug for ClientHandle { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 59 | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 60 | formatter |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 61 | .debug_struct("ClientHandle") |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 62 | .finish_non_exhaustive() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 63 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 64 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 65 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 66 | /// a command's answer. drop it if you don't care, the command still runs |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 67 | #[derive(Debug)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 68 | #[must_use = "dropping it is fine but then you'll never know"] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 69 | pub struct Pending(oneshot::Receiver<Result<CommandOutput, Error>>); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 70 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 71 | impl Future for Pending { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 72 | type Output = Result<CommandOutput, Error>; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 73 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 74 | fn poll(mut self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Self::Output> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 75 | Pin::new(&mut self.0) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 76 | .poll(context) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 77 | .map(|result| result.unwrap_or_else(|_| Err(Error::interrupted()))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 78 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 79 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 80 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 81 | impl ClientHandle { |
f12377bce9b9 | atagen | 2026-09-26 12:32 UTC | 82 | /// current credentials, it holds secrets. the engine saves it for you unless the |
f12377bce9b9 | atagen | 2026-09-26 12:32 UTC | 83 | /// session was built `without_persistence` |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 84 | #[cfg(any(feature = "sqlite", feature = "indexeddb"))] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 85 | pub fn session_record(&self) -> Result<crate::SessionRecord, crate::AccountError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 86 | crate::account::session_record(&self.client) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 87 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 88 | |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 89 | /// the bearer token. it rotates on every refresh so ask again after a 401 rather than |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 90 | /// keeping it, and keep it in memory and away from all but the homeserver's media endpoints |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 91 | pub fn access_token(&self) -> Option<String> { |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 92 | self.client.access_token() |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 93 | } |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 94 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 95 | /// queue a command, waiting for room in the queue if there isn't any |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 96 | pub async fn send(&self, command: Command) -> Result<Pending, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 97 | let (request, pending) = Request::new(command); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 98 | self.requests |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 99 | .send(request) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 100 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 101 | .map_err(|_| Error::interrupted())?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 102 | Ok(pending) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 103 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 104 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 105 | /// queue a command or fail with `QueueFull` right now |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 106 | pub fn try_send(&self, command: Command) -> Result<Pending, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 107 | let (request, pending) = Request::new(command); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 108 | self.requests |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 109 | .try_send(request) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 110 | .map_err(|error| match error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 111 | mpsc::error::TrySendError::Full(_) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 112 | Error::new(ErrorKind::QueueFull, "the command queue is full") |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 113 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 114 | mpsc::error::TrySendError::Closed(_) => Error::interrupted(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 115 | })?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 116 | Ok(pending) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 117 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 118 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 119 | /// queue a command and wait for its answer. timeline sends answer once the |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 120 | /// sdk send queue has them, delivery shows up later as the item's send state |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 121 | pub async fn execute(&self, command: Command) -> Result<CommandOutput, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 122 | self.send(command).await?.await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 123 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 124 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 125 | async fn run(&self, command: Command) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 126 | self.execute(command).await.map(drop) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 127 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 128 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 129 | async fn run_for_room(&self, command: RoomCommand) -> Result<OwnedRoomId, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 130 | match self.execute(Command::Room(command)).await? { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 131 | CommandOutput::Room(room_id) => Ok(room_id), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 132 | output => Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 133 | ErrorKind::Other, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 134 | format!("expected a room but got {output:?}"), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 135 | )), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 136 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 137 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 138 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 139 | pub async fn shutdown(&self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 140 | self.run(Command::Lifecycle(LifecycleCommand::Shutdown)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 141 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 142 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 143 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 144 | pub async fn logout(&self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 145 | self.run(Command::Account(AccountCommand::Logout)).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 146 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 147 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 148 | pub async fn delete_devices( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 149 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 150 | device_ids: Vec<OwnedDeviceId>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 151 | auth: Option<InteractiveAuth>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 152 | ) -> Result<InteractiveAuthOutcome, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 153 | match self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 154 | .run(Command::Account(AccountCommand::DeleteDevices { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 155 | device_ids, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 156 | auth, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 157 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 158 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 159 | { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 160 | Ok(()) => Ok(InteractiveAuthOutcome::Completed), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 161 | Err(Error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 162 | challenge: Some(challenge), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 163 | .. |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 164 | }) => Ok(InteractiveAuthOutcome::Challenge(*challenge)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 165 | Err(error) => Err(error), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 166 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 167 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 168 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 169 | pub async fn rename_device( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 170 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 171 | device_id: OwnedDeviceId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 172 | display_name: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 173 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 174 | self.run(Command::Account(AccountCommand::RenameDevice { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 175 | device_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 176 | display_name: display_name.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 177 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 178 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 179 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 180 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 181 | pub async fn set_global_account_data( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 182 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 183 | event_type: GlobalAccountDataEventType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 184 | content: Raw<AnyGlobalAccountDataEventContent>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 185 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 186 | self.run(Command::Account(AccountCommand::SetAccountData { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 187 | event_type, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 188 | content, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 189 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 190 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 191 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 192 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 193 | pub async fn set_room_account_data( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 194 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 195 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 196 | event_type: RoomAccountDataEventType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 197 | content: Raw<AnyRoomAccountDataEventContent>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 198 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 199 | self.run(Command::Room(RoomCommand::SetAccountData { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 200 | room_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 201 | event_type, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 202 | content, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 203 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 204 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 205 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 206 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 207 | pub async fn set_room_notification_mode( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 208 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 209 | room_id: OwnedRoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 210 | mode: RoomNotificationMode, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 211 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 212 | self.run(Command::Notification(NotificationCommand::SetRoomMode { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 213 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 214 | mode, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 215 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 216 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 217 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 218 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 219 | pub async fn reset_room_notification_mode(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 220 | self.run(Command::Notification(NotificationCommand::ResetRoomMode( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 221 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 222 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 223 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 224 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 225 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 226 | pub async fn set_default_notification_mode( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 227 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 228 | encrypted: bool, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 229 | one_to_one: bool, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 230 | mode: RoomNotificationMode, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 231 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 232 | self.run(Command::Notification(NotificationCommand::SetDefaultMode { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 233 | encrypted, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 234 | one_to_one, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 235 | mode, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 236 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 237 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 238 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 239 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 240 | pub async fn add_notification_keyword(&self, keyword: impl Into<String>) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 241 | self.run(Command::Notification(NotificationCommand::AddKeyword( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 242 | keyword.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 243 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 244 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 245 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 246 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 247 | pub async fn remove_notification_keyword( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 248 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 249 | keyword: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 250 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 251 | self.run(Command::Notification(NotificationCommand::RemoveKeyword( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 252 | keyword.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 253 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 254 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 255 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 256 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 257 | pub async fn open_room(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 258 | self.run(Command::Room(RoomCommand::Open(room_id))).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 259 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 260 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 261 | pub async fn close_room(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 262 | self.run(Command::Room(RoomCommand::Close(room_id))).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 263 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 264 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 265 | pub async fn open_thread( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 266 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 267 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 268 | root_event_id: OwnedEventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 269 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 270 | self.run(Command::Timeline(TimelineCommand::OpenThread { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 271 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 272 | root_event_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 273 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 274 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 275 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 276 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 277 | pub async fn close_thread( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 278 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 279 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 280 | root_event_id: OwnedEventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 281 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 282 | self.run(Command::Timeline(TimelineCommand::CloseThread { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 283 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 284 | root_event_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 285 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 286 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 287 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 288 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 289 | pub async fn resync(&self, timeline_id: TimelineId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 290 | self.run(Command::Timeline(TimelineCommand::Resync { timeline_id })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 291 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 292 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 293 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 294 | pub async fn paginate(&self, timeline_id: TimelineId, limit: u16) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 295 | self.run(Command::Timeline(TimelineCommand::Paginate { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 296 | timeline_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 297 | limit, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 298 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 299 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 300 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 301 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 302 | pub async fn send_message( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 303 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 304 | timeline_id: TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 305 | content: MessageContent, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 306 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 307 | self.run(Command::Timeline(TimelineCommand::Send { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 308 | timeline_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 309 | content, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 310 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 311 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 312 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 313 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 314 | pub async fn edit_message( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 315 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 316 | timeline_id: TimelineId, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 317 | target: impl Into<EventRef>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 318 | content: MessageEditContent, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 319 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 320 | self.run(Command::Timeline(TimelineCommand::Edit { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 321 | timeline_id, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 322 | target: target.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 323 | content, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 324 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 325 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 326 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 327 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 328 | pub async fn redact( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 329 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 330 | timeline_id: TimelineId, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 331 | target: impl Into<EventRef>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 332 | reason: Option<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 333 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 334 | self.run(Command::Timeline(TimelineCommand::Redact { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 335 | timeline_id, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 336 | target: target.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 337 | reason, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 338 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 339 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 340 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 341 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 342 | pub async fn toggle_reaction( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 343 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 344 | timeline_id: TimelineId, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 345 | target: impl Into<EventRef>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 346 | key: impl Into<String>, |
8fa8a7cde89c | atagen | 2026-10-08 12:39 UTC | 347 | shortcode: Option<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 348 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 349 | self.run(Command::Timeline(TimelineCommand::ToggleReaction { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 350 | timeline_id, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 351 | target: target.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 352 | key: key.into(), |
8fa8a7cde89c | atagen | 2026-10-08 12:39 UTC | 353 | shortcode, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 354 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 355 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 356 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 357 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 358 | pub async fn mark_read( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 359 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 360 | timeline_id: TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 361 | event_id: OwnedEventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 362 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 363 | self.run(Command::Timeline(TimelineCommand::MarkRead { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 364 | timeline_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 365 | event_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 366 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 367 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 368 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 369 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 370 | pub async fn set_typing(&self, room_id: OwnedRoomId, typing: bool) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 371 | self.run(Command::Room(RoomCommand::SetTyping { room_id, typing })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 372 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 373 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 374 | |
38c4caecdb3d | atagen | 2026-09-26 13:35 UTC | 375 | pub async fn prepare_to_send(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
38c4caecdb3d | atagen | 2026-09-26 13:35 UTC | 376 | self.run(Command::Room(RoomCommand::PrepareToSend(room_id))) |
38c4caecdb3d | atagen | 2026-09-26 13:35 UTC | 377 | .await |
38c4caecdb3d | atagen | 2026-09-26 13:35 UTC | 378 | } |
38c4caecdb3d | atagen | 2026-09-26 13:35 UTC | 379 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 380 | pub async fn join_room( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 381 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 382 | room: OwnedRoomOrAliasId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 383 | via: Vec<OwnedServerName>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 384 | ) -> Result<OwnedRoomId, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 385 | self.run_for_room(RoomCommand::Join { room, via }).await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 386 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 387 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 388 | pub async fn leave_room(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 389 | self.run(Command::Room(RoomCommand::Leave(room_id))).await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 390 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 391 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 392 | pub async fn forget_room(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 393 | self.run(Command::Room(RoomCommand::Forget(room_id))).await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 394 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 395 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 396 | pub async fn accept_invite(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 397 | self.run(Command::Room(RoomCommand::AcceptInvite(room_id))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 398 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 399 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 400 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 401 | pub async fn reject_invite(&self, room_id: OwnedRoomId) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 402 | self.run(Command::Room(RoomCommand::RejectInvite(room_id))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 403 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 404 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 405 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 406 | pub async fn invite_user( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 407 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 408 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 409 | user_id: OwnedUserId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 410 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 411 | self.run(Command::Room(RoomCommand::InviteUser { room_id, user_id })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 412 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 413 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 414 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 415 | pub async fn kick_user( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 416 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 417 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 418 | user_id: OwnedUserId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 419 | reason: Option<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 420 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 421 | self.run(Command::Room(RoomCommand::KickUser { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 422 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 423 | user_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 424 | reason, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 425 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 426 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 427 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 428 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 429 | pub async fn ban_user( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 430 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 431 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 432 | user_id: OwnedUserId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 433 | reason: Option<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 434 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 435 | self.run(Command::Room(RoomCommand::BanUser { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 436 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 437 | user_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 438 | reason, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 439 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 440 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 441 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 442 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 443 | pub async fn unban_user( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 444 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 445 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 446 | user_id: OwnedUserId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 447 | reason: Option<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 448 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 449 | self.run(Command::Room(RoomCommand::UnbanUser { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 450 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 451 | user_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 452 | reason, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 453 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 454 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 455 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 456 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 457 | pub async fn set_power_levels( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 458 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 459 | room_id: OwnedRoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 460 | changes: PowerLevelChanges, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 461 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 462 | self.run(Command::Room(RoomCommand::SetPowerLevels { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 463 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 464 | changes, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 465 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 466 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 467 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 468 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 469 | pub async fn set_user_power_level( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 470 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 471 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 472 | user_id: OwnedUserId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 473 | level: i64, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 474 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 475 | self.run(Command::Room(RoomCommand::SetUserPowerLevel { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 476 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 477 | user_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 478 | level, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 479 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 480 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 481 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 482 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 483 | pub async fn create_room(&self, options: CreateRoomOptions) -> Result<OwnedRoomId, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 484 | self.run_for_room(RoomCommand::Create(options)).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 485 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 486 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 487 | /// hands back the existing dm with them if there is one |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 488 | pub async fn create_direct(&self, user_id: OwnedUserId) -> Result<OwnedRoomId, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 489 | self.run_for_room(RoomCommand::CreateDirect(user_id)).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 490 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 491 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 492 | pub async fn cancel_send( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 493 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 494 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 495 | transaction_id: OwnedTransactionId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 496 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 497 | self.run(Command::Room(RoomCommand::CancelSend { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 498 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 499 | transaction_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 500 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 501 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 502 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 503 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 504 | pub async fn retry_send( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 505 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 506 | room_id: OwnedRoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 507 | transaction_id: OwnedTransactionId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 508 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 509 | self.run(Command::Room(RoomCommand::RetrySend { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 510 | room_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 511 | transaction_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 512 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 513 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 514 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 515 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 516 | pub async fn upload(&self, upload: AttachmentUpload) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 517 | self.run(Command::Media(MediaCommand::Upload(upload))).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 518 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 519 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 520 | pub async fn recover(&self, recovery_key: impl Into<String>) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 521 | self.run(Command::Encryption(EncryptionCommand::Recover( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 522 | recovery_key.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 523 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 524 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 525 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 526 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 527 | pub async fn create_key_backup(&self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 528 | self.run(Command::Encryption(EncryptionCommand::CreateKeyBackup)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 529 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 530 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 531 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 532 | pub async fn enable_key_backup(&self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 533 | self.run(Command::Encryption(EncryptionCommand::EnableKeyBackup)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 534 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 535 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 536 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 537 | pub async fn disable_key_backup(&self, delete_from_server: bool) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 538 | self.run(Command::Encryption(EncryptionCommand::DisableKeyBackup { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 539 | delete_from_server, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 540 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 541 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 542 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 543 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 544 | pub async fn recover_key_backup(&self, recovery_key: impl Into<String>) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 545 | self.run(Command::Encryption(EncryptionCommand::RecoverKeyBackup( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 546 | recovery_key.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 547 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 548 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 549 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 550 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 551 | pub async fn start_verification(&self, target: VerificationTarget) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 552 | self.run(Command::Encryption(EncryptionCommand::StartVerification( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 553 | target, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 554 | ))) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 555 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 556 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 557 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 558 | pub async fn verify(&self, action: VerificationAction) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 559 | self.run(Command::Encryption(EncryptionCommand::Verify(action))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 560 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 561 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 562 | |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 563 | /// bytes for an avatar, or for media a retained timeline showed you. concurrent asks share |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 564 | /// one download |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 565 | pub async fn media(&self, media_id: &MediaId, size: MediaSize) -> Result<Media, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 566 | self.media.timeline_media(media_id, size).await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 567 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 568 | |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 569 | /// where `media` would fetch from, for a host streaming big files itself. the byte cap |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 570 | /// doesn't apply since nothing is buffered |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 571 | pub async fn media_source( |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 572 | &self, |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 573 | media_id: &MediaId, |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 574 | size: MediaSize, |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 575 | ) -> Result<MediaLocation, Error> { |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 576 | self.media.media_location(media_id, size).await |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 577 | } |
5b21b919d1e6 | atagen | 2026-09-27 11:47 UTC | 578 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 579 | /// the space graph builds on first use and then keeps itself current |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 580 | async fn spaces(&self) -> &SpaceService { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 581 | self.spaces |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 582 | .get_or_init(|| SpaceService::new(self.client.clone())) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 583 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 584 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 585 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 586 | pub async fn rooms(&self) -> Vec<RoomSummary> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 587 | room_summaries(&self.client, self.spaces().await).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 588 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 589 | |
17e042fbc331 | atagen | 2026-10-08 12:39 UTC | 590 | pub async fn image_packs(&self) -> Result<ImagePacks, Error> { |
17e042fbc331 | atagen | 2026-10-08 12:39 UTC | 591 | image_packs(&self.client).await |
17e042fbc331 | atagen | 2026-10-08 12:39 UTC | 592 | } |
17e042fbc331 | atagen | 2026-10-08 12:39 UTC | 593 | |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 594 | /// the homeserver's preview of a page, `None` when it has none. the homeserver sees every |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 595 | /// url asked about, so a host decides whether encrypted rooms ask at all |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 596 | pub async fn url_preview(&self, url: &str) -> Result<Option<LinkPreview>, Error> { |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 597 | self.media.url_preview(url).await |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 598 | } |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 599 | |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 600 | /// whether the room and the user's settings let link previews show here |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 601 | pub async fn url_previews_allowed(&self, room_id: &RoomId) -> Result<bool, Error> { |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 602 | url_previews_allowed(&self.room(room_id)?).await |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 603 | } |
0291516d40b5 | atagen | 2026-10-22 08:31 UTC | 604 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 605 | /// browse a space the way the server sees it, rooms you haven't joined included |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 606 | pub async fn space_hierarchy(&self, space_id: OwnedRoomId) -> SpaceHierarchy { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 607 | SpaceHierarchy(SpaceRoomList::new(self.client.clone(), space_id).await) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 608 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 609 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 610 | pub async fn own_profile(&self) -> Result<Profile, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 611 | let user_id = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 612 | .client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 613 | .user_id() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 614 | .ok_or_else(|| Error::new(ErrorKind::Unauthenticated, "the client is not logged in"))? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 615 | .to_owned(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 616 | let response = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 617 | .client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 618 | .account() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 619 | .fetch_user_profile() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 620 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 621 | .map_err(|source| Error::from_sdk("fetching the profile failed", source))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 622 | profile(user_id, &response) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 623 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 624 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 625 | pub async fn user_profile(&self, user_id: &UserId) -> Result<Profile, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 626 | let response = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 627 | .client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 628 | .account() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 629 | .fetch_user_profile_of(user_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 630 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 631 | .map_err(|source| Error::from_sdk("fetching the profile failed", source))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 632 | profile(user_id.to_owned(), &response) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 633 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 634 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 635 | pub async fn set_display_name(&self, name: Option<String>) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 636 | self.run(Command::Account(AccountCommand::SetDisplayName(name))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 637 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 638 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 639 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 640 | pub async fn set_avatar(&self, avatar: Option<OwnedMxcUri>) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 641 | self.run(Command::Account(AccountCommand::SetAvatar(avatar))) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 642 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 643 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 644 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 645 | pub async fn upload_avatar( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 646 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 647 | mimetype: impl Into<String>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 648 | bytes: Vec<u8>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 649 | ) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 650 | self.run(Command::Account(AccountCommand::UploadAvatar { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 651 | mimetype: mimetype.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 652 | bytes, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 653 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 654 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 655 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 656 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 657 | /// unencrypted, for room avatars and anything else that only needs the uri |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 658 | pub async fn upload_media( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 659 | &self, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 660 | mimetype: impl Into<String>, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 661 | bytes: Vec<u8>, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 662 | ) -> Result<OwnedMxcUri, Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 663 | let command = Command::Account(AccountCommand::UploadMedia { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 664 | mimetype: mimetype.into(), |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 665 | bytes, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 666 | }); |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 667 | match self.execute(command).await? { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 668 | CommandOutput::Mxc(uri) => Ok(uri), |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 669 | output => Err(Error::new( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 670 | ErrorKind::Other, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 671 | format!("expected an mxc but got {output:?}"), |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 672 | )), |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 673 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 674 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 675 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 676 | pub async fn ignore_user(&self, user_id: OwnedUserId) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 677 | self.run(Command::Account(AccountCommand::IgnoreUser(user_id))) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 678 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 679 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 680 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 681 | pub async fn unignore_user(&self, user_id: OwnedUserId) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 682 | self.run(Command::Account(AccountCommand::UnignoreUser(user_id))) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 683 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 684 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 685 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 686 | /// writes msc3230 orders so these spaces sort in exactly this sequence, touching as few as it can |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 687 | pub async fn reorder_spaces(&self, order: Vec<OwnedRoomId>) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 688 | self.run(Command::Account(AccountCommand::ReorderSpaces(order))) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 689 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 690 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 691 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 692 | /// adding m.favourite drops m.lowpriority, the way Element does |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 693 | pub async fn set_favourite(&self, room_id: OwnedRoomId, favourite: bool) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 694 | self.run(Command::Room(RoomCommand::SetFavourite { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 695 | room_id, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 696 | favourite, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 697 | })) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 698 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 699 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 700 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 701 | /// None goes back to your global name |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 702 | pub async fn set_room_display_name( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 703 | &self, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 704 | room_id: OwnedRoomId, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 705 | name: Option<String>, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 706 | ) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 707 | self.run(Command::Room(RoomCommand::SetOwnDisplayName { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 708 | room_id, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 709 | name, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 710 | })) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 711 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 712 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 713 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 714 | /// None goes back to your global avatar |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 715 | pub async fn set_room_avatar( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 716 | &self, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 717 | room_id: OwnedRoomId, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 718 | avatar: Option<OwnedMxcUri>, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 719 | ) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 720 | self.run(Command::Room(RoomCommand::SetOwnAvatar { room_id, avatar })) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 721 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 722 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 723 | |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 724 | /// muting drops them below what sending a message takes, unmuting puts a muted user back |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 725 | /// at users_default and leaves anyone else alone. `ErrorKind::Forbidden` if you can't |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 726 | pub async fn mute_user( |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 727 | &self, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 728 | room_id: OwnedRoomId, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 729 | user_id: OwnedUserId, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 730 | muted: bool, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 731 | ) -> Result<(), Error> { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 732 | self.run(Command::Room(RoomCommand::MuteUser { |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 733 | room_id, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 734 | user_id, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 735 | muted, |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 736 | })) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 737 | .await |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 738 | } |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 739 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 740 | /// body defaults to the shortcode |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 741 | pub async fn send_sticker( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 742 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 743 | room_id: OwnedRoomId, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 744 | pack_id: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 745 | shortcode: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 746 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 747 | self.run(Command::Pack(PackCommand::SendSticker { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 748 | room_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 749 | pack_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 750 | shortcode, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 751 | })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 752 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 753 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 754 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 755 | /// fails if the state key already holds a pack |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 756 | pub async fn create_room_pack( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 757 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 758 | room_id: OwnedRoomId, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 759 | state_key: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 760 | display_name: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 761 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 762 | self.run(Command::Pack(PackCommand::CreateRoomPack { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 763 | room_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 764 | state_key, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 765 | display_name, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 766 | })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 767 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 768 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 769 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 770 | pub async fn delete_pack(&self, pack: ImagePackSource) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 771 | self.run(Command::Pack(PackCommand::Delete(pack))).await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 772 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 773 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 774 | pub async fn set_pack_meta( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 775 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 776 | pack: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 777 | display_name: Patch<String>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 778 | avatar: Patch<OwnedMxcUri>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 779 | usage: Patch<Vec<PackUsage>>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 780 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 781 | self.run(Command::Pack(PackCommand::SetMeta { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 782 | pack, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 783 | display_name, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 784 | avatar, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 785 | usage, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 786 | })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 787 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 788 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 789 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 790 | /// adds or replaces by shortcode. a replaced image keeps its info unless the url changed |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 791 | pub async fn put_pack_image( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 792 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 793 | pack: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 794 | shortcode: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 795 | mxc: OwnedMxcUri, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 796 | body: Option<String>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 797 | usage: Option<Vec<PackUsage>>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 798 | info: Option<PackImageInfo>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 799 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 800 | self.run(Command::Pack(PackCommand::PutImage { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 801 | pack, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 802 | shortcode, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 803 | mxc, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 804 | body, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 805 | usage, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 806 | info, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 807 | })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 808 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 809 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 810 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 811 | pub async fn rename_pack_image( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 812 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 813 | pack: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 814 | from: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 815 | to: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 816 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 817 | self.run(Command::Pack(PackCommand::RenameImage { pack, from, to })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 818 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 819 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 820 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 821 | pub async fn remove_pack_image( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 822 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 823 | pack: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 824 | shortcode: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 825 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 826 | self.run(Command::Pack(PackCommand::RemoveImage { pack, shortcode })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 827 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 828 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 829 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 830 | pub async fn set_pack_enabled_everywhere( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 831 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 832 | room_id: OwnedRoomId, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 833 | state_key: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 834 | enabled: bool, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 835 | ) -> Result<(), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 836 | self.run(Command::Pack(PackCommand::SetEnabledEverywhere { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 837 | room_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 838 | state_key, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 839 | enabled, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 840 | })) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 841 | .await |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 842 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 843 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 844 | /// the same uri when it already lives on your homeserver |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 845 | pub async fn rehost_media(&self, mxc: OwnedMxcUri) -> Result<OwnedMxcUri, Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 846 | match self |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 847 | .execute(Command::Pack(PackCommand::Rehost(mxc))) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 848 | .await? |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 849 | { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 850 | CommandOutput::Mxc(uri) => Ok(uri), |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 851 | output => Err(unexpected("an mxc", &output)), |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 852 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 853 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 854 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 855 | /// hands back the shortcode it ended up under |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 856 | pub async fn clone_pack_image( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 857 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 858 | from_pack: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 859 | shortcode: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 860 | to: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 861 | ) -> Result<String, Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 862 | let (mut shortcodes, _) = self |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 863 | .run_clone(PackCommand::CloneImage { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 864 | from_pack, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 865 | shortcode, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 866 | to, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 867 | }) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 868 | .await?; |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 869 | shortcodes |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 870 | .pop() |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 871 | .ok_or_else(|| unexpected("a shortcode", &CommandOutput::Done)) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 872 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 873 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 874 | /// hands back the shortcode it ended up under |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 875 | pub async fn clone_sticker( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 876 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 877 | room_id: OwnedRoomId, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 878 | event_id: OwnedEventId, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 879 | to: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 880 | shortcode: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 881 | ) -> Result<String, Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 882 | let (mut shortcodes, _) = self |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 883 | .run_clone(PackCommand::CloneSticker { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 884 | room_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 885 | event_id, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 886 | to, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 887 | shortcode, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 888 | }) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 889 | .await?; |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 890 | shortcodes |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 891 | .pop() |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 892 | .ok_or_else(|| unexpected("a shortcode", &CommandOutput::Done)) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 893 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 894 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 895 | /// hands back the shortcodes that couldn't be fetched, everything else is written |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 896 | pub async fn clone_pack( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 897 | &self, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 898 | from_pack: String, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 899 | to: ImagePackSource, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 900 | display_name: Option<String>, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 901 | ) -> Result<Vec<String>, Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 902 | let (_, skipped) = self |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 903 | .run_clone(PackCommand::ClonePack { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 904 | from_pack, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 905 | to, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 906 | display_name, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 907 | }) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 908 | .await?; |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 909 | Ok(skipped) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 910 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 911 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 912 | async fn run_clone(&self, command: PackCommand) -> Result<(Vec<String>, Vec<String>), Error> { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 913 | match self.execute(Command::Pack(command)).await? { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 914 | CommandOutput::Cloned { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 915 | shortcodes, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 916 | skipped, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 917 | } => Ok((shortcodes, skipped)), |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 918 | output => Err(unexpected("a clone", &output)), |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 919 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 920 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 921 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 922 | pub async fn rooms_filtered(&self, filter: &RoomListFilter) -> Vec<RoomSummary> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 923 | let matcher = filter.matcher(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 924 | self.rooms() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 925 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 926 | .into_iter() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 927 | .filter(|room| matcher.matches(room)) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 928 | .collect() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 929 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 930 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 931 | pub async fn devices(&self) -> Result<Vec<OwnDevice>, Error> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 932 | let current_device_id = self.client.device_id(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 933 | Ok(self |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 934 | .client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 935 | .devices() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 936 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 937 | .map_err(|source| Error::from_http("listing devices failed", source))? |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 938 | .devices |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 939 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 940 | .map(|device| OwnDevice { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 941 | current: current_device_id == Some(device.device_id.as_ref()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 942 | device_id: device.device_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 943 | display_name: device.display_name, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 944 | last_seen_ip: device.last_seen_ip, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 945 | last_seen_timestamp_ms: device.last_seen_ts.map(|timestamp| timestamp.get().into()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 946 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 947 | .collect()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 948 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 949 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 950 | fn room(&self, room_id: &RoomId) -> Result<matrix_sdk::Room, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 951 | self.client |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 952 | .get_room(room_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 953 | .ok_or_else(Error::room_unknown) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 954 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 955 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 956 | pub async fn room_notification_settings( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 957 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 958 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 959 | ) -> Result<Option<RoomNotificationSettings>, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 960 | let room = self.room(room_id)?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 961 | let custom = room.user_defined_notification_mode().await; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 962 | let mode = match custom { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 963 | Some(mode) => mode, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 964 | None => match room.notification_mode().await { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 965 | Some(mode) => mode, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 966 | None => return Ok(None), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 967 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 968 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 969 | Ok(Some(RoomNotificationSettings { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 970 | mode: crate::normalise::notification_mode(mode), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 971 | custom: custom.is_some(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 972 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 973 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 974 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 975 | pub async fn notification_keywords(&self) -> Vec<String> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 976 | self.client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 977 | .notification_settings() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 978 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 979 | .enabled_keywords() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 980 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 981 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 982 | .collect() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 983 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 984 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 985 | pub async fn resolve_push_notification( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 986 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 987 | room_id: &RoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 988 | event_id: &EventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 989 | ) -> Result<PushNotificationStatus, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 990 | let notification_failed = |source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 991 | Error::with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 992 | ErrorKind::Other, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 993 | "resolving the push notification failed", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 994 | source, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 995 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 996 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 997 | let client = self |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 998 | .notification_client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 999 | .get_or_try_init(|| async { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1000 | NotificationClient::new( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1001 | self.client.clone(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1002 | NotificationProcessSetup::SingleProcess { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1003 | sync_service: self.sync_service.clone(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1004 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1005 | ) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1006 | .await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1007 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1008 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1009 | .map_err(notification_failed)?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1010 | let status = client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1011 | .get_notification(room_id, event_id) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1012 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1013 | .map_err(notification_failed)?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1014 | Ok(normalise_push_notification(room_id, event_id, status)) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1015 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1016 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1017 | pub async fn members( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1018 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1019 | room_id: &RoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1020 | filter: MemberFilter, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1021 | ) -> Result<Vec<MemberSummary>, Error> { |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1022 | let room = self.room(room_id)?; |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1023 | // stores have been seen with members_synced persisted over a partial |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1024 | // roster, and the sdk never asks /members again once it's set |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1025 | if self |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1026 | .members_checked |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1027 | .lock() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1028 | .unwrap() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1029 | .insert(room_id.to_owned()) |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1030 | { |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1031 | room.mark_members_missing(); |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1032 | } |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1033 | list_members(&room, filter).await |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1034 | } |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1035 | |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1036 | /// drop the cached roster for a room and fetch /members again |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1037 | pub async fn refresh_members( |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1038 | &self, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1039 | room_id: &RoomId, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1040 | filter: MemberFilter, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1041 | ) -> Result<Vec<MemberSummary>, Error> { |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1042 | let room = self.room(room_id)?; |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1043 | room.mark_members_missing(); |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1044 | self.members_checked |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1045 | .lock() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1046 | .unwrap() |
9bd34e25bb86 | atagen | 2026-10-24 07:23 UTC | 1047 | .insert(room_id.to_owned()); |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1048 | list_members(&room, filter).await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1049 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1050 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1051 | pub async fn room_power_levels(&self, room_id: &RoomId) -> Result<RoomPowerLevels, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1052 | let levels = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1053 | .room(room_id)? |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1054 | .power_levels() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1055 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1056 | .map_err(|source| Error::from_sdk("reading power levels failed", source.into()))?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1057 | Ok(RoomPowerLevels { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1058 | ban: levels.ban.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1059 | invite: levels.invite.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1060 | kick: levels.kick.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1061 | redact: levels.redact.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1062 | events_default: levels.events_default.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1063 | state_default: levels.state_default.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1064 | users_default: levels.users_default.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1065 | room_notification: levels.notifications.room.into(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1066 | users: levels |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1067 | .users |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1068 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1069 | .map(|(user_id, level)| (user_id, level.into())) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1070 | .collect(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1071 | events: levels |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1072 | .events |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1073 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1074 | .map(|(event_type, level)| (event_type.to_string(), level.into())) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1075 | .collect(), |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1076 | creators: levels |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1077 | .rules |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1078 | .privileged_creators |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1079 | .into_iter() |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1080 | .flatten() |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1081 | .collect(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1082 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1083 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1084 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1085 | pub async fn pending_send_ids( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1086 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1087 | room_id: &RoomId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1088 | ) -> Result<Vec<OwnedTransactionId>, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1089 | let (echoes, _) = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1090 | .room(room_id)? |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1091 | .send_queue() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1092 | .subscribe() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1093 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1094 | .map_err(|source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1095 | Error::with_source(ErrorKind::Store, "reading the send queue failed", source) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1096 | })?; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1097 | Ok(echoes |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1098 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1099 | .filter(|echo| { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1100 | matches!( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1101 | echo.content, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1102 | matrix_sdk::send_queue::LocalEchoContent::Event { .. } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1103 | ) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1104 | }) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1105 | .map(|echo| echo.transaction_id) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1106 | .collect()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1107 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1108 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1109 | pub async fn global_account_data( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1110 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1111 | event_type: GlobalAccountDataEventType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1112 | ) -> Result<Option<Raw<AnyGlobalAccountDataEventContent>>, Error> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1113 | self.client |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1114 | .account() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1115 | .account_data_raw(event_type) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1116 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1117 | .map_err(|source| Error::from_sdk("reading account data failed", source)) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1118 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1119 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1120 | pub async fn room_account_data( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1121 | &self, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1122 | room_id: &RoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1123 | event_type: RoomAccountDataEventType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1124 | ) -> Result<Option<Raw<AnyRoomAccountDataEvent>>, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1125 | self.room(room_id)? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1126 | .account_data(event_type) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1127 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1128 | .map_err(|source| Error::from_sdk("reading room account data failed", source)) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1129 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1130 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1131 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1132 | pub fn connection_state(&self) -> watch::Receiver<ConnectionState> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1133 | self.connection.clone() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1134 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1135 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1136 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1137 | pub fn encryption_state(&self) -> Option<EncryptionState> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1138 | let device_id = self.client.device_id()?.to_owned(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1139 | let encryption = self.client.encryption(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1140 | Some(encryption_state( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1141 | device_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1142 | encryption.recovery().state(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1143 | encryption.verification_state().get(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1144 | encryption.backups().state(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1145 | )) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1146 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1147 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1148 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1149 | /// one space's hierarchy, a page at a time. hold on to it while you browse, it remembers where it got to |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1150 | pub struct SpaceHierarchy(SpaceRoomList); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1151 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1152 | impl fmt::Debug for SpaceHierarchy { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1153 | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1154 | formatter |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1155 | .debug_struct("SpaceHierarchy") |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1156 | .finish_non_exhaustive() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1157 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1158 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1159 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1160 | impl SpaceHierarchy { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1161 | /// fetches the next page. a no-op once the end is reached or while a page is in flight |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1162 | pub async fn paginate(&self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1163 | self.0.paginate().await.map_err(|source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1164 | Error::with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1165 | ErrorKind::Server, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1166 | "fetching the space hierarchy failed", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1167 | source, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1168 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1169 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1170 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1171 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1172 | /// everything fetched so far, the space itself excluded |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1173 | pub async fn rooms(&self) -> Vec<SpaceChild> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1174 | self.0.rooms().await.into_iter().map(space_child).collect() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1175 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1176 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1177 | #[must_use] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1178 | pub fn end_reached(&self) -> bool { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1179 | matches!( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1180 | self.0.pagination_state(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1181 | SpaceRoomListPaginationState::Idle { end_reached: true } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1182 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1183 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1184 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1185 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1186 | fn profile( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1187 | user_id: OwnedUserId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1188 | response: &ruma::api::client::profile::get_profile::v3::Response, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1189 | ) -> Result<Profile, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1190 | use ruma::api::client::profile::{AvatarUrl, DisplayName}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1191 | let malformed = |source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1192 | Error::with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1193 | ErrorKind::Server, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1194 | "the server sent a malformed profile", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1195 | source, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1196 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1197 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1198 | Ok(Profile { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1199 | user_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1200 | display_name: response.get_static::<DisplayName>().map_err(malformed)?, |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1201 | avatar: response |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1202 | .get_static::<AvatarUrl>() |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1203 | .map_err(malformed)? |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1204 | .as_deref() |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1205 | .map(MediaId::plain), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1206 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1207 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1208 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1209 | #[derive(Debug)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1210 | pub(crate) struct Request { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1211 | pub(crate) command: Command, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1212 | pub(crate) reply: Responder, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1213 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1214 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1215 | impl Request { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1216 | fn new(command: Command) -> (Self, Pending) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1217 | let (reply, pending) = oneshot::channel(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1218 | ( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1219 | Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1220 | command, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1221 | reply: Responder(reply), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1222 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1223 | Pending(pending), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1224 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1225 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1226 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1227 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1228 | /// whoever holds this owes the caller an answer. dropping it answers `Interrupted` |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1229 | #[derive(Debug)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1230 | pub(crate) struct Responder(oneshot::Sender<Result<CommandOutput, Error>>); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1231 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1232 | impl Responder { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1233 | pub(crate) fn channel() -> (Self, Pending) { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1234 | let (reply, pending) = oneshot::channel(); |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1235 | (Self(reply), Pending(pending)) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1236 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1237 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1238 | pub(crate) fn send(self, result: Result<CommandOutput, Error>) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1239 | if let Err(error) = &result { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1240 | tracing::debug!(%error, kind = ?error.kind, "command failed"); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1241 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1242 | let _ = self.0.send(result); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1243 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1244 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1245 | pub(crate) fn done(self, result: Result<(), Error>) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1246 | self.send(result.map(|()| CommandOutput::Done)); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1247 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1248 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1249 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1250 | #[derive(Debug)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1251 | pub struct EventStream { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1252 | events: mpsc::Receiver<Event>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1253 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1254 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1255 | impl EventStream { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1256 | pub async fn recv(&mut self) -> Option<Event> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1257 | self.events.recv().await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1258 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1259 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1260 | pub fn try_recv(&mut self) -> Result<Event, mpsc::error::TryRecvError> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1261 | self.events.try_recv() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1262 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1263 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1264 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1265 | impl futures_util::Stream for EventStream { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1266 | type Item = Event; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1267 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1268 | fn poll_next(mut self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Option<Self::Item>> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1269 | self.events.poll_recv(context) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1270 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1271 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1272 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1273 | #[derive(Debug)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1274 | pub(crate) struct DriverPort { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1275 | requests: mpsc::Receiver<Request>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1276 | events: mpsc::Sender<Event>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1277 | connection: watch::Sender<ConnectionState>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1278 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1279 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1280 | #[derive(Clone, Debug)] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1281 | pub(crate) struct EventSender(mpsc::Sender<Event>); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1282 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1283 | impl EventSender { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1284 | pub(crate) async fn send(&self, event: Event) -> Result<(), SendEventError> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1285 | self.0.send(event).await.map_err(|_| SendEventError) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1286 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1287 | |
411bc1c78b65 | atagen | 2026-10-22 07:39 UTC | 1288 | pub(crate) async fn reserve(&self) -> Result<mpsc::Permit<'_, Event>, SendEventError> { |
411bc1c78b65 | atagen | 2026-10-22 07:39 UTC | 1289 | self.0.reserve().await.map_err(|_| SendEventError) |
411bc1c78b65 | atagen | 2026-10-22 07:39 UTC | 1290 | } |
411bc1c78b65 | atagen | 2026-10-22 07:39 UTC | 1291 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1292 | /// resolves once every `EventStream` is gone |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1293 | pub(crate) async fn closed(&self) { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1294 | self.0.closed().await; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1295 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1296 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1297 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1298 | impl DriverPort { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1299 | pub(crate) fn event_sender(&self) -> EventSender { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1300 | EventSender(self.events.clone()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1301 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1302 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1303 | pub(crate) fn connection_sender(&self) -> watch::Sender<ConnectionState> { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1304 | self.connection.clone() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1305 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1306 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1307 | pub(crate) async fn recv(&mut self) -> Option<Request> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1308 | self.requests.recv().await |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1309 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1310 | |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1311 | pub(crate) fn try_recv(&mut self) -> Option<Request> { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1312 | self.requests.try_recv().ok() |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1313 | } |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 1314 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1315 | pub(crate) fn close(&mut self) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1316 | self.requests.close(); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1317 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1318 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1319 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1320 | #[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1321 | #[error("the event receiver has closed")] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1322 | pub(crate) struct SendEventError; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1323 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1324 | #[must_use] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1325 | pub(crate) fn transport_pair( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1326 | client: Client, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1327 | sync_service: Arc<SyncService>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1328 | media: Arc<MediaService>, |
a250c7fa43fb | atagen | 2026-09-26 13:35 UTC | 1329 | store_lock: Option<Arc<StoreLock>>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1330 | command_capacity: usize, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1331 | event_capacity: usize, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1332 | ) -> (ClientHandle, DriverPort, EventStream) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1333 | let (request_tx, request_rx) = mpsc::channel(command_capacity); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1334 | let (event_tx, event_rx) = mpsc::channel(event_capacity); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1335 | let (connection_tx, connection_rx) = watch::channel(ConnectionState::Idle); |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1336 | ( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1337 | ClientHandle { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1338 | requests: request_tx, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1339 | client, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1340 | connection: connection_rx, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1341 | notification_client: Arc::new(OnceCell::new()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1342 | sync_service, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1343 | media, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1344 | spaces: Arc::new(OnceCell::new()), |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1345 | members_checked: Arc::default(), |
a250c7fa43fb | atagen | 2026-09-26 13:35 UTC | 1346 | _store_lock: store_lock, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1347 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1348 | DriverPort { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1349 | requests: request_rx, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1350 | events: event_tx, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1351 | connection: connection_tx, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1352 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1353 | EventStream { events: event_rx }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1354 | ) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1355 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1356 | |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1357 | async fn list_members( |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1358 | room: &matrix_sdk::Room, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1359 | filter: MemberFilter, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1360 | ) -> Result<Vec<MemberSummary>, Error> { |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1361 | let memberships = match filter { |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1362 | MemberFilter::Active => RoomMemberships::ACTIVE, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1363 | MemberFilter::Joined => RoomMemberships::JOIN, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1364 | MemberFilter::Invited => RoomMemberships::INVITE, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1365 | MemberFilter::Banned => RoomMemberships::BAN, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1366 | MemberFilter::Left => RoomMemberships::LEAVE, |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1367 | // An empty mask is the SDK's unfiltered wildcard: it matches every |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1368 | // membership, including custom states that `all()` would exclude. |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1369 | MemberFilter::All => RoomMemberships::empty(), |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1370 | }; |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1371 | Ok(room |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1372 | .members(memberships) |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1373 | .await |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1374 | .map_err(|source| Error::from_sdk("listing members failed", source))? |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1375 | .into_iter() |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1376 | .map(member_summary) |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1377 | .collect()) |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1378 | } |
121a56ce119d | atagen | 2026-10-24 06:42 UTC | 1379 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1380 | fn normalise_push_notification( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1381 | room_id: &RoomId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1382 | event_id: &EventId, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1383 | status: NotificationStatus, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1384 | ) -> PushNotificationStatus { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1385 | match status { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1386 | NotificationStatus::Event(item) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1387 | let event = match &item.raw_event { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1388 | RawNotificationEvent::Timeline(event) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1389 | PushNotificationEvent::Timeline(event.clone()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1390 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1391 | RawNotificationEvent::Invite(event) => PushNotificationEvent::Invite(event.clone()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1392 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1393 | PushNotificationStatus::Event(Box::new(PushNotification { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1394 | event_id: event_id.to_owned(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1395 | event, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1396 | sender: PushNotificationSender { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1397 | user_id: item.event.sender().to_owned(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1398 | display_name: item.sender_display_name, |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1399 | avatar_url: item.sender_avatar_url.as_deref().map(MediaId::plain), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1400 | name_ambiguous: item.is_sender_name_ambiguous, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1401 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1402 | room: PushNotificationRoom { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1403 | room_id: room_id.to_owned(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1404 | name: item.room_computed_display_name, |
5d2974de5826 | atagen | 2026-10-08 11:29 UTC | 1405 | avatar_url: item.room_avatar_url.as_deref().map(MediaId::plain), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1406 | canonical_alias: item |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1407 | .room_canonical_alias |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1408 | .as_deref() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1409 | .and_then(|alias| alias.parse().ok()), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1410 | topic: item.room_topic, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1411 | encrypted: item.is_room_encrypted, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1412 | direct: item.room_is_dm, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1413 | joined_members_count: item.joined_members_count, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1414 | service_members: item |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1415 | .service_members |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1416 | .into_iter() |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1417 | .filter_map(|user_id| user_id.parse().ok()) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1418 | .collect(), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1419 | active_service_members_count: item.active_service_members_count, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1420 | space: item.is_space, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1421 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1422 | noisy: item.is_noisy, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1423 | has_mention: item.has_mention, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1424 | thread_id: item.thread_id, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1425 | })) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1426 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1427 | NotificationStatus::EventNotFound => PushNotificationStatus::NotFound, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1428 | NotificationStatus::EventFilteredOut => PushNotificationStatus::FilteredOut, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1429 | NotificationStatus::EventRedacted => PushNotificationStatus::Redacted, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1430 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 1431 | } |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1432 | |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1433 | fn unexpected(wanted: &str, output: &CommandOutput) -> Error { |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1434 | Error::new( |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1435 | ErrorKind::Other, |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1436 | format!("expected {wanted} but got {output:?}"), |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1437 | ) |
fa51490b6ae9 | atagen | 2026-10-24 08:41 UTC | 1438 | } |