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