1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 1 | use std::{collections::HashSet, future::Future, panic::AssertUnwindSafe, sync::Arc}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 2 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 3 | use futures_util::{FutureExt, StreamExt}; |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 4 | use matrix_sdk::SendOutsideWasm; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 5 | use matrix_sdk::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 6 | room::edit::EditedContent, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 7 | room::reply::{EnforceThread, Reply as SdkReply}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 8 | ruma::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 9 | api::client::receipt::create_receipt::v3::ReceiptType, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 10 | events::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 11 | Mentions, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 12 | room::message::{ |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 13 | AddMentions, Relation, ReplyWithinThread, RoomMessageEventContentWithoutRelation, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 14 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 15 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 16 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 17 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 18 | use matrix_sdk_ui::timeline::{Timeline, TimelineEventItemId}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 19 | use ruma::{OwnedEventId, OwnedUserId}; |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 20 | use tokio::sync::mpsc; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 21 | |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 22 | use super::executor::{EngineBoxFuture, JoinHandle, TaskSet, spawn}; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 23 | use crate::{ |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 24 | Error, ErrorKind, Event, EventRef, HistoryState, MessageContent, MessageEditContent, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 25 | MessageMentions, RichText, TimelineCommand, TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 26 | engine::MediaService, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 27 | normalise::{MediaScope, normalise_timeline, normalise_timeline_diffs}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 28 | transport::{EventSender, Responder, SendEventError}, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 29 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 30 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 31 | const PAGINATION_QUEUE: usize = 32; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 32 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 33 | /// long-lived tasks inside a room actor report panics here so the actor can die loudly |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 34 | #[derive(Clone)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 35 | pub(super) struct Supervisor(mpsc::UnboundedSender<&'static str>); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 36 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 37 | impl Supervisor { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 38 | pub(super) fn new() -> (Self, mpsc::UnboundedReceiver<&'static str>) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 39 | let (sender, receiver) = mpsc::unbounded_channel(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 40 | (Self(sender), receiver) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 41 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 42 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 43 | pub(super) fn spawn( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 44 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 45 | label: &'static str, |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 46 | task: impl Future<Output = ()> + SendOutsideWasm + 'static, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 47 | ) -> JoinHandle<()> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 48 | let panics = self.0.clone(); |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 49 | spawn(async move { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 50 | if AssertUnwindSafe(task).catch_unwind().await.is_err() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 51 | let _ = panics.send(label); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 52 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 53 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 54 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 55 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 56 | |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 57 | /// aborts its task when dropped, so an actor that dies mid-flight takes its helpers with it |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 58 | pub(super) struct TaskGuard(pub(super) JoinHandle<()>); |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 59 | |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 60 | impl Drop for TaskGuard { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 61 | fn drop(&mut self) { |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 62 | self.0.abort(); |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 63 | } |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 64 | } |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 65 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 66 | /// what a timeline session needs from the room that owns it |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 67 | #[derive(Clone)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 68 | pub(super) struct SessionContext { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 69 | pub(super) events: EventSender, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 70 | pub(super) media: Arc<MediaService>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 71 | pub(super) current_user_id: Option<OwnedUserId>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 72 | pub(super) initial_history_limit: u16, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 73 | pub(super) supervisor: Supervisor, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 74 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 75 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 76 | pub(super) struct TimelineSession { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 77 | pub(super) id: TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 78 | timeline: Arc<Timeline>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 79 | context: SessionContext, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 80 | scope: MediaScope, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 81 | watcher: JoinHandle<()>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 82 | pagination: mpsc::Sender<PaginationRequest>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 83 | pagination_worker: JoinHandle<()>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 84 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 85 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 86 | struct PaginationRequest { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 87 | limit: u16, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 88 | reply: Option<Responder>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 89 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 90 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 91 | impl TimelineSession { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 92 | pub(super) async fn start( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 93 | id: TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 94 | timeline: Timeline, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 95 | context: SessionContext, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 96 | ) -> Result<Self, SendEventError> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 97 | let timeline = Arc::new(timeline); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 98 | let scope = MediaScope::new(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 99 | let watcher = start_watcher(&id, &timeline, &context, &scope).await?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 100 | let (pagination, requests) = mpsc::channel(PAGINATION_QUEUE); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 101 | let pagination_worker = context.supervisor.spawn( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 102 | "pagination worker", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 103 | run_pagination( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 104 | requests, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 105 | timeline.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 106 | context.events.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 107 | id.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 108 | ), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 109 | ); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 110 | let session = Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 111 | id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 112 | timeline, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 113 | scope, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 114 | watcher, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 115 | pagination, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 116 | pagination_worker, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 117 | context, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 118 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 119 | if session.context.initial_history_limit > 0 { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 120 | session.paginate(session.context.initial_history_limit, None); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 121 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 122 | Ok(session) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 123 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 124 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 125 | /// swaps in a fresh watcher. the old one is dead before the reset goes out, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 126 | /// so no stale diff can land after it |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 127 | pub(super) async fn resync(&mut self) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 128 | self.watcher.abort(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 129 | let _ = (&mut self.watcher).await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 130 | self.watcher = start_watcher(&self.id, &self.timeline, &self.context, &self.scope) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 131 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 132 | .map_err(|_| Error::new(ErrorKind::Timeline, "timeline reset could not be sent"))?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 133 | Ok(()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 134 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 135 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 136 | pub(super) fn paginate(&self, limit: u16, reply: Option<Responder>) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 137 | if let Err(error) = self.pagination.try_send(PaginationRequest { limit, reply }) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 138 | let (request, error) = match error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 139 | mpsc::error::TrySendError::Full(request) => ( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 140 | request, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 141 | Error::new(ErrorKind::QueueFull, "pagination queue is full"), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 142 | ), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 143 | mpsc::error::TrySendError::Closed(request) => ( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 144 | request, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 145 | Error::new(ErrorKind::TimelineNotOpen, "timeline is closing"), |
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 | if let Some(reply) = request.reply { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 149 | reply.done(Err(error)); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 150 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 151 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 152 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 153 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 154 | /// pending paginations answer `Interrupted` as their responders drop |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 155 | pub(super) async fn close(mut self) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 156 | self.pagination_worker.abort(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 157 | let _ = (&mut self.pagination_worker).await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 158 | self.watcher.abort(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 159 | let _ = (&mut self.watcher).await; |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 160 | // after the watcher, or a last diff could register media for a timeline that's gone |
5a52012c9b1d | atagen | 2026-09-24 23:45 UTC | 161 | self.context.media.release(&self.scope).await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 162 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 163 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 164 | pub(super) async fn execute( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 165 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 166 | command: TimelineCommand, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 167 | reply: Responder, |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 168 | work: &mut TaskSet<()>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 169 | ) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 170 | let timeline = self.timeline.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 171 | let thread_root = self.id.thread_root().cloned(); |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 172 | let background: EngineBoxFuture<'static, Result<(), Error>> = match command { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 173 | TimelineCommand::Paginate { limit, .. } => return self.paginate(limit, Some(reply)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 174 | // network-bound, so it runs beside the actor instead of queueing the room behind it |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 175 | TimelineCommand::Redact { target, reason, .. } => Box::pin(async move { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 176 | timeline |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 177 | .redact(&item_id(target), reason.as_deref()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 178 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 179 | .map_err(timeline_error) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 180 | }), |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 181 | TimelineCommand::ToggleReaction { target, key, .. } => Box::pin(async move { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 182 | timeline |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 183 | .toggle_reaction(&item_id(target), &key) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 184 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 185 | .map(drop) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 186 | .map_err(timeline_error) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 187 | }), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 188 | TimelineCommand::MarkRead { event_id, .. } => Box::pin(async move { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 189 | let receipt_failed = |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 190 | |source| Error::from_sdk("sending read receipt failed", source); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 191 | timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 192 | .send_single_receipt(ReceiptType::Read, event_id.clone()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 193 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 194 | .map_err(receipt_failed)?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 195 | if thread_root.is_none() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 196 | timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 197 | .send_single_receipt(ReceiptType::FullyRead, event_id) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 198 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 199 | .map_err(receipt_failed)?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 200 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 201 | Ok(()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 202 | }), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 203 | command => return reply.done(self.execute_serial(command).await), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 204 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 205 | work.spawn(async move { reply.done(background.await) }); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 206 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 207 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 208 | /// sends stay on the actor so they hit the send queue in the order they were asked for |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 209 | async fn execute_serial(&self, command: TimelineCommand) -> Result<(), Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 210 | let timeline = &self.timeline; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 211 | match command { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 212 | TimelineCommand::Send { content, .. } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 213 | let body = match &content { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 214 | MessageContent::Text { content, .. } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 215 | | MessageContent::Emote { content, .. } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 216 | | MessageContent::Reply { content, .. } => &content.body, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 217 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 218 | if body.trim().is_empty() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 219 | return Err(Error::new(ErrorKind::EmptyBody, "message body is empty")); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 220 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 221 | let content = match content { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 222 | MessageContent::Text { content, mentions } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 223 | message_content(content, mentions, false).with_relation(None) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 224 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 225 | MessageContent::Emote { content, mentions } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 226 | message_content(content, mentions, true).with_relation(None) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 227 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 228 | MessageContent::Reply { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 229 | event_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 230 | content, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 231 | mentions, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 232 | notify_replied_to, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 233 | } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 234 | self.reply_content(event_id, content, mentions, notify_replied_to) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 235 | .await? |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 236 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 237 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 238 | timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 239 | .send(content.into()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 240 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 241 | .map(drop) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 242 | .map_err(timeline_error) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 243 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 244 | TimelineCommand::Edit { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 245 | target, content, .. |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 246 | } => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 247 | let (content, mentions, emote) = match content { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 248 | MessageEditContent::Text { content, mentions } => (content, mentions, false), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 249 | MessageEditContent::Emote { content, mentions } => (content, mentions, true), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 250 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 251 | if content.body.trim().is_empty() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 252 | return Err(Error::new(ErrorKind::EmptyBody, "message body is empty")); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 253 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 254 | timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 255 | .edit( |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 256 | &item_id(target), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 257 | EditedContent::RoomMessage(message_content(content, mentions, emote)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 258 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 259 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 260 | .map_err(timeline_error) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 261 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 262 | _ => Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 263 | ErrorKind::Other, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 264 | "timeline command was misrouted", |
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 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 268 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 269 | async fn reply_content( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 270 | &self, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 271 | event_id: OwnedEventId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 272 | content: RichText, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 273 | mentions: MessageMentions, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 274 | notify_replied_to: bool, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 275 | ) -> Result<matrix_sdk::ruma::events::room::message::RoomMessageEventContent, Error> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 276 | let thread_root = self.id.thread_root(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 277 | let content = self |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 278 | .timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 279 | .room() |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 280 | .make_reply_event( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 281 | message_content(content, mentions, false), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 282 | SdkReply { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 283 | event_id, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 284 | enforce_thread: if thread_root.is_some() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 285 | EnforceThread::Threaded(ReplyWithinThread::Yes) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 286 | } else { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 287 | EnforceThread::MaybeThreaded |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 288 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 289 | add_mentions: if notify_replied_to { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 290 | AddMentions::Yes |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 291 | } else { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 292 | AddMentions::No |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 293 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 294 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 295 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 296 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 297 | .map_err(|source| { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 298 | Error::with_source(ErrorKind::Timeline, "reply operation failed", source) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 299 | })?; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 300 | if let Some(thread_root) = thread_root |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 301 | && !matches!( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 302 | content.relates_to.as_ref(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 303 | Some(Relation::Thread(thread)) if &thread.event_id == thread_root |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 304 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 305 | { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 306 | return Err(Error::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 307 | ErrorKind::Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 308 | "reply target does not belong to the selected thread", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 309 | )); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 310 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 311 | Ok(content) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 312 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 313 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 314 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 315 | impl Drop for TimelineSession { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 316 | fn drop(&mut self) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 317 | self.watcher.abort(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 318 | self.pagination_worker.abort(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 319 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 320 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 321 | |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 322 | fn item_id(target: EventRef) -> TimelineEventItemId { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 323 | match target { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 324 | EventRef::Remote(event_id) => TimelineEventItemId::EventId(event_id), |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 325 | EventRef::Local(transaction_id) => TimelineEventItemId::TransactionId(transaction_id), |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 326 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 327 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 328 | |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 329 | /// the sdk leaves a reply's target unloaded until someone asks, so the watcher asks, once per event |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 330 | struct ReplyFetcher { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 331 | timeline: Arc<Timeline>, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 332 | asked: HashSet<OwnedEventId>, |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 333 | fetches: TaskSet<()>, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 334 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 335 | |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 336 | impl ReplyFetcher { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 337 | fn fetch(&mut self, missing: Vec<OwnedEventId>) { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 338 | for event_id in missing { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 339 | if self.asked.insert(event_id.clone()) { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 340 | let timeline = self.timeline.clone(); |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 341 | self.fetches.spawn(async move { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 342 | if let Err(error) = timeline.fetch_details_for_event(&event_id).await { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 343 | tracing::debug!(%event_id, %error, "fetching reply details failed"); |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 344 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 345 | }); |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 346 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 347 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 348 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 349 | } |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 350 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 351 | async fn start_watcher( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 352 | id: &TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 353 | timeline: &Arc<Timeline>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 354 | context: &SessionContext, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 355 | scope: &MediaScope, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 356 | ) -> Result<JoinHandle<()>, SendEventError> { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 357 | let (items, mut stream) = timeline.subscribe().await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 358 | let current_user_id = context.current_user_id.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 359 | let normalised = normalise_timeline(items.iter(), current_user_id.as_deref(), scope); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 360 | context.media.register(normalised.media).await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 361 | context |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 362 | .events |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 363 | .send(Event::TimelineReset { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 364 | timeline_id: id.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 365 | items: normalised.items, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 366 | }) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 367 | .await?; |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 368 | let mut replies = ReplyFetcher { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 369 | timeline: timeline.clone(), |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 370 | asked: HashSet::new(), |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 371 | fetches: TaskSet::new(), |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 372 | }; |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 373 | replies.fetch(normalised.missing_replies); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 374 | let id = id.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 375 | let events = context.events.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 376 | let media = context.media.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 377 | let scope = scope.clone(); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 378 | Ok(context.supervisor.spawn("timeline watcher", async move { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 379 | loop { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 380 | let diffs = tokio::select! { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 381 | diffs = stream.next() => match diffs { |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 382 | Some(diffs) => diffs, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 383 | None => return, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 384 | }, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 385 | Some(_) = replies.fetches.join_next(), if !replies.fetches.is_empty() => continue, |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 386 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 387 | let normalised = normalise_timeline_diffs(diffs, current_user_id.as_deref(), &scope); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 388 | media.register(normalised.media).await; |
960ac0721079 | atagen | 2026-09-25 00:24 UTC | 389 | replies.fetch(normalised.missing_replies); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 390 | let event = Event::TimelineChanged { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 391 | timeline_id: id.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 392 | diffs: normalised.diffs, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 393 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 394 | if events.send(event).await.is_err() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 395 | return; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 396 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 397 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 398 | })) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 399 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 400 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 401 | async fn run_pagination( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 402 | mut requests: mpsc::Receiver<PaginationRequest>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 403 | timeline: Arc<Timeline>, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 404 | events: EventSender, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 405 | timeline_id: TimelineId, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 406 | ) { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 407 | while let Some(PaginationRequest { limit, reply }) = requests.recv().await { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 408 | let history = |state| Event::HistoryChanged { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 409 | timeline_id: timeline_id.clone(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 410 | state, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 411 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 412 | if events.send(history(HistoryState::Loading)).await.is_err() { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 413 | return; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 414 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 415 | let result = timeline |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 416 | .paginate_backwards(limit.max(1)) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 417 | .await |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 418 | .map_err(timeline_error); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 419 | let state = match &result { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 420 | Ok(true) => HistoryState::StartReached, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 421 | Ok(false) => HistoryState::Idle, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 422 | Err(error) => HistoryState::Failed(error.to_string()), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 423 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 424 | let _ = events.send(history(state)).await; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 425 | if let Some(reply) = reply { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 426 | reply.done(result.map(drop)); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 427 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 428 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 429 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 430 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 431 | fn message_content( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 432 | content: RichText, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 433 | mentions: MessageMentions, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 434 | emote: bool, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 435 | ) -> RoomMessageEventContentWithoutRelation { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 436 | let content = match content.formatted_body { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 437 | Some(formatted_body) if emote => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 438 | RoomMessageEventContentWithoutRelation::emote_html(content.body, formatted_body) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 439 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 440 | Some(formatted_body) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 441 | RoomMessageEventContentWithoutRelation::text_html(content.body, formatted_body) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 442 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 443 | None if emote => RoomMessageEventContentWithoutRelation::emote_plain(content.body), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 444 | None => RoomMessageEventContentWithoutRelation::text_plain(content.body), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 445 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 446 | let content = content.add_mentions(Mentions::with_user_ids(mentions.user_ids)); |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 447 | if mentions.room { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 448 | content.add_mentions(Mentions::with_room_mention()) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 449 | } else { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 450 | content |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 451 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 452 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 453 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 454 | pub(super) fn timeline_error(source: matrix_sdk_ui::timeline::Error) -> Error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 455 | Error::with_source(ErrorKind::Timeline, "timeline operation failed", source) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 456 | } |