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