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