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