| 1 | use std::sync::Arc; |
| 2 | use std::time::Duration; |
| 3 | |
| 4 | use calling::EngineEvent; |
| 5 | use chatsvc::{ |
| 6 | Calendar, CalendarEvent, EventKind, MessageEvent, Pins, Realtime, RealtimeConfig, |
| 7 | RealtimeEvent, StatusKind, TypingEvent, |
| 8 | }; |
| 9 | use chrono::{DateTime, Local, Offset, Utc}; |
| 10 | use graph::Graph; |
| 11 | use session::{Session, SessionConfig, Transport}; |
| 12 | use store::Store; |
| 13 | use teams_core::{ChatsvcFolderSource, CoreEvent, SyncEngine}; |
| 14 | use tokio::sync::{Notify, mpsc, watch}; |
| 15 | |
| 16 | use crate::call::{CallLauncher, fetch_window}; |
| 17 | use crate::presence_link::{self, LinkSignal}; |
| 18 | |
| 19 | pub type Engine = SyncEngine<Graph>; |
| 20 | |
| 21 | const CONNECT_RETRY: Duration = Duration::from_secs(8); |
| 22 | const REFRESH_INTERVAL: Duration = Duration::from_secs(120); |
| 23 | const REFRESH_SETTLE: Duration = Duration::from_secs(2); |
| 24 | const PINS_INTERVAL: Duration = Duration::from_secs(90); |
| 25 | const CALENDAR_INTERVAL: Duration = Duration::from_secs(5 * 60); |
| 26 | const CALENDAR_MIN_GAP: Duration = Duration::from_secs(30); |
| 27 | const REALTIME_RETRY: Duration = Duration::from_secs(15); |
| 28 | const PRESENCE_RESUBSCRIBE: Duration = Duration::from_secs(30 * 60); |
| 29 | const MAX_ERROR_CHARS: usize = 120; |
| 30 | const IMAGE_DIRECTORY: &str = "images"; |
| 31 | const IMAGE_CACHE_MAX_BYTES: u64 = 200 * 1024 * 1024; |
| 32 | |
| 33 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 34 | pub enum ConnectionState { |
| 35 | Connecting, |
| 36 | Online, |
| 37 | NoBrowser, |
| 38 | NoAppTab, |
| 39 | LoginRequired, |
| 40 | Failed(String), |
| 41 | } |
| 42 | |
| 43 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 44 | pub enum LiveState { |
| 45 | Off, |
| 46 | Connecting, |
| 47 | Live, |
| 48 | Reconnecting, |
| 49 | MessageLoss, |
| 50 | Failed, |
| 51 | } |
| 52 | |
| 53 | pub enum BackendEvent { |
| 54 | Connection(ConnectionState), |
| 55 | Engine(Arc<Engine>), |
| 56 | Calls(Arc<CallLauncher>), |
| 57 | Calendar(Vec<CalendarEvent>), |
| 58 | CalendarNudge(mpsc::UnboundedSender<()>), |
| 59 | Ring(EngineEvent), |
| 60 | ThreadChanged(String), |
| 61 | Core(CoreEvent), |
| 62 | Live(LiveState), |
| 63 | Typing(TypingEvent), |
| 64 | Favorites(Vec<String>), |
| 65 | Synced(DateTime<Utc>), |
| 66 | } |
| 67 | |
| 68 | type EventSender = mpsc::UnboundedSender<BackendEvent>; |
| 69 | |
| 70 | pub fn classify_session_error(error: &session::Error) -> ConnectionState { |
| 71 | match error { |
| 72 | session::Error::NoBrowser { .. } => ConnectionState::NoBrowser, |
| 73 | session::Error::NoAppTab => ConnectionState::NoAppTab, |
| 74 | session::Error::LoginRequired(_) | session::Error::NoFreshToken { .. } => { |
| 75 | ConnectionState::LoginRequired |
| 76 | } |
| 77 | other => ConnectionState::Failed(shorten(&other.to_string())), |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | pub fn classify_core_error(error: &teams_core::Error) -> ConnectionState { |
| 82 | match error { |
| 83 | teams_core::Error::Graph(graph::Error::Session(inner)) => classify_session_error(inner), |
| 84 | other => ConnectionState::Failed(shorten(&other.to_string())), |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | fn image_directory() -> Option<std::path::PathBuf> { |
| 89 | directories::ProjectDirs::from("", "", store::DATA_DIR_NAME) |
| 90 | .map(|directories| directories.data_local_dir().join(IMAGE_DIRECTORY)) |
| 91 | } |
| 92 | |
| 93 | fn shorten(text: &str) -> String { |
| 94 | text.chars().take(MAX_ERROR_CHARS).collect() |
| 95 | } |
| 96 | |
| 97 | pub fn live_state_for(kind: StatusKind) -> LiveState { |
| 98 | match kind { |
| 99 | StatusKind::Connected => LiveState::Live, |
| 100 | StatusKind::Disconnected => LiveState::Reconnecting, |
| 101 | StatusKind::MessageLoss => LiveState::MessageLoss, |
| 102 | StatusKind::Error => LiveState::Failed, |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | fn link_signal_for(kind: StatusKind) -> Option<LinkSignal> { |
| 107 | match kind { |
| 108 | StatusKind::Connected => Some(LinkSignal::Connected), |
| 109 | StatusKind::Disconnected => Some(LinkSignal::Disconnected), |
| 110 | StatusKind::MessageLoss | StatusKind::Error => None, |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | pub fn start( |
| 115 | store: Arc<Store>, |
| 116 | transport: Arc<dyn Transport>, |
| 117 | ringable: bool, |
| 118 | activity: watch::Receiver<bool>, |
| 119 | ) -> mpsc::UnboundedReceiver<BackendEvent> { |
| 120 | let (sender, receiver) = mpsc::unbounded_channel(); |
| 121 | crate::runtime::handle().spawn(supervise(store, transport, ringable, activity, sender)); |
| 122 | receiver |
| 123 | } |
| 124 | |
| 125 | async fn supervise( |
| 126 | store: Arc<Store>, |
| 127 | transport: Arc<dyn Transport>, |
| 128 | ringable: bool, |
| 129 | activity: watch::Receiver<bool>, |
| 130 | events: EventSender, |
| 131 | ) { |
| 132 | let _ = events.send(BackendEvent::Connection(ConnectionState::Connecting)); |
| 133 | let session = loop { |
| 134 | match Session::with_transport(transport.clone(), SessionConfig::default()).await { |
| 135 | Ok(session) => break session, |
| 136 | Err(error) => { |
| 137 | let _ = events.send(BackendEvent::Connection(classify_session_error(&error))); |
| 138 | tokio::time::sleep(CONNECT_RETRY).await; |
| 139 | } |
| 140 | } |
| 141 | }; |
| 142 | let build = || { |
| 143 | SyncEngine::new(Graph::new(session.clone()), store.clone()) |
| 144 | .with_folder_source(Arc::new(ChatsvcFolderSource::new(&session))) |
| 145 | }; |
| 146 | let engine = image_directory() |
| 147 | .and_then(|directory| { |
| 148 | build() |
| 149 | .with_image_dir(&directory, IMAGE_CACHE_MAX_BYTES) |
| 150 | .ok() |
| 151 | }) |
| 152 | .unwrap_or_else(build); |
| 153 | let engine = Arc::new(engine); |
| 154 | let _ = events.send(BackendEvent::Engine(engine.clone())); |
| 155 | let ring_events = events.clone(); |
| 156 | let launcher = CallLauncher::start(transport, ringable, move |event| { |
| 157 | let _ = ring_events.send(BackendEvent::Ring(event)); |
| 158 | }); |
| 159 | let _ = events.send(BackendEvent::Calls(launcher)); |
| 160 | tokio::spawn(forward_core_events(engine.clone(), events.clone())); |
| 161 | let (nudge, nudges) = mpsc::unbounded_channel(); |
| 162 | let resend = Arc::new(Notify::new()); |
| 163 | let link = presence_link::start(&session, activity.clone(), resend.clone()); |
| 164 | tokio::spawn(realtime_loop( |
| 165 | session.clone(), |
| 166 | engine.clone(), |
| 167 | events.clone(), |
| 168 | nudge, |
| 169 | activity, |
| 170 | resend, |
| 171 | link, |
| 172 | )); |
| 173 | tokio::spawn(calendar_loop(session.clone(), events.clone())); |
| 174 | tokio::spawn(pins_loop(session, events.clone())); |
| 175 | tokio::spawn(presence_resubscribe_loop(engine.clone())); |
| 176 | refresh_loop(engine, events, nudges).await; |
| 177 | } |
| 178 | |
| 179 | async fn forward_core_events(engine: Arc<Engine>, events: EventSender) { |
| 180 | let mut receiver = engine.subscribe(); |
| 181 | loop { |
| 182 | let event = match receiver.recv().await { |
| 183 | Ok(event) => event, |
| 184 | Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => CoreEvent::SidebarChanged, |
| 185 | Err(tokio::sync::broadcast::error::RecvError::Closed) => return, |
| 186 | }; |
| 187 | if events.send(BackendEvent::Core(event)).is_err() { |
| 188 | return; |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | async fn refresh_loop( |
| 194 | engine: Arc<Engine>, |
| 195 | events: EventSender, |
| 196 | mut nudges: mpsc::UnboundedReceiver<()>, |
| 197 | ) { |
| 198 | let mut interval = tokio::time::interval(REFRESH_INTERVAL); |
| 199 | loop { |
| 200 | tokio::select! { |
| 201 | _ = interval.tick() => {} |
| 202 | nudge = nudges.recv() => { |
| 203 | if nudge.is_none() { |
| 204 | return; |
| 205 | } |
| 206 | tokio::time::sleep(REFRESH_SETTLE).await; |
| 207 | while nudges.try_recv().is_ok() {} |
| 208 | } |
| 209 | } |
| 210 | match engine.refresh_sidebar().await { |
| 211 | Ok(_) => { |
| 212 | if let Err(error) = engine.refresh_folders().await { |
| 213 | crate::diagnostics::record(format!( |
| 214 | "sync: chat folders and channel layout not refreshed: {error}" |
| 215 | )); |
| 216 | } |
| 217 | let _ = events.send(BackendEvent::Connection(ConnectionState::Online)); |
| 218 | let _ = events.send(BackendEvent::Synced(Utc::now())); |
| 219 | } |
| 220 | Err(error) => { |
| 221 | let _ = events.send(BackendEvent::Connection(classify_core_error(&error))); |
| 222 | tokio::time::sleep(CONNECT_RETRY).await; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | async fn realtime_loop( |
| 229 | session: Session, |
| 230 | engine: Arc<Engine>, |
| 231 | events: EventSender, |
| 232 | nudge: mpsc::UnboundedSender<()>, |
| 233 | mut activity: watch::Receiver<bool>, |
| 234 | resend: Arc<Notify>, |
| 235 | link: mpsc::UnboundedSender<LinkSignal>, |
| 236 | ) { |
| 237 | loop { |
| 238 | let _ = events.send(BackendEvent::Live(LiveState::Connecting)); |
| 239 | let config = RealtimeConfig { |
| 240 | initially_active: *activity.borrow(), |
| 241 | ..RealtimeConfig::default() |
| 242 | }; |
| 243 | match Realtime::start_with(&session, config).await { |
| 244 | Ok(mut realtime) => { |
| 245 | loop { |
| 246 | let event = tokio::select! { |
| 247 | event = realtime.recv() => event, |
| 248 | Ok(()) = activity.changed() => { |
| 249 | realtime.set_activity(*activity.borrow_and_update()); |
| 250 | continue; |
| 251 | } |
| 252 | _ = resend.notified() => { |
| 253 | realtime.resend_activity(); |
| 254 | continue; |
| 255 | } |
| 256 | }; |
| 257 | let Some(event) = event else { break }; |
| 258 | match event { |
| 259 | RealtimeEvent::Message(message) => { |
| 260 | let _ = events.send(BackendEvent::Live(LiveState::Live)); |
| 261 | if let Some(conversation_id) = thread_signal(&message) { |
| 262 | let _ = events.send(BackendEvent::ThreadChanged(conversation_id)); |
| 263 | } |
| 264 | let receipt_engine = engine.clone(); |
| 265 | let receipt_event = message.clone(); |
| 266 | engine.handle_pin_event(&message); |
| 267 | tokio::spawn(async move { |
| 268 | receipt_engine.handle_receipt_event(&receipt_event).await |
| 269 | }); |
| 270 | tokio::spawn(handle_message_event( |
| 271 | engine.clone(), |
| 272 | nudge.clone(), |
| 273 | message, |
| 274 | )); |
| 275 | } |
| 276 | RealtimeEvent::Typing(typing) => { |
| 277 | let _ = events.send(BackendEvent::Typing(typing)); |
| 278 | } |
| 279 | RealtimeEvent::Status(status) => { |
| 280 | let _ = events.send(BackendEvent::Live(live_state_for(status.kind))); |
| 281 | if let Some(signal) = link_signal_for(status.kind) { |
| 282 | let _ = link.send(signal); |
| 283 | } |
| 284 | let receipt_engine = engine.clone(); |
| 285 | let receipt_status = status.clone(); |
| 286 | tokio::spawn(async move { |
| 287 | receipt_engine.handle_receipt_status(&receipt_status).await |
| 288 | }); |
| 289 | } |
| 290 | RealtimeEvent::Presence(updates) => { |
| 291 | engine.apply_presence(&updates); |
| 292 | if engine.concerns_me(&updates) { |
| 293 | let engine = engine.clone(); |
| 294 | tokio::spawn(async move { engine.refresh_own_status().await }); |
| 295 | } |
| 296 | } |
| 297 | RealtimeEvent::Endpoint(endpoint) => { |
| 298 | let _ = link.send(LinkSignal::Endpoint(endpoint.endpoint_id.clone())); |
| 299 | let engine = engine.clone(); |
| 300 | tokio::spawn(async move { engine.presence_endpoint(endpoint).await }); |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | let _ = events.send(BackendEvent::Live(LiveState::Reconnecting)); |
| 305 | let _ = link.send(LinkSignal::Disconnected); |
| 306 | } |
| 307 | Err(_) => { |
| 308 | let _ = events.send(BackendEvent::Live(LiveState::Failed)); |
| 309 | let _ = link.send(LinkSignal::Disconnected); |
| 310 | } |
| 311 | } |
| 312 | tokio::time::sleep(REALTIME_RETRY).await; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | async fn presence_resubscribe_loop(engine: Arc<Engine>) { |
| 317 | let mut interval = tokio::time::interval(PRESENCE_RESUBSCRIBE); |
| 318 | interval.tick().await; |
| 319 | loop { |
| 320 | interval.tick().await; |
| 321 | let _ = engine.resubscribe_presence().await; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | /// A thread update or a new message in a chat can start or end a meeting (the call bubble is a message). |
| 326 | pub fn thread_signal(event: &MessageEvent) -> Option<String> { |
| 327 | match event.kind { |
| 328 | EventKind::ThreadUpdate | EventKind::NewMessage => event.conversation_id.clone(), |
| 329 | _ => None, |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | pub fn refresh_plan(event: &MessageEvent) -> Option<RefreshPlan> { |
| 334 | let conversation_id = event.conversation_id.clone()?; |
| 335 | match event.kind { |
| 336 | EventKind::MessageUpdate => Some(match event.message_id.clone() { |
| 337 | Some(message_id) => RefreshPlan::Message { |
| 338 | conversation_id, |
| 339 | message_id, |
| 340 | }, |
| 341 | None => RefreshPlan::Newer { conversation_id }, |
| 342 | }), |
| 343 | EventKind::NewMessage => Some(RefreshPlan::Newer { conversation_id }), |
| 344 | _ => None, |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 349 | pub enum RefreshPlan { |
| 350 | Newer { |
| 351 | conversation_id: String, |
| 352 | }, |
| 353 | Message { |
| 354 | conversation_id: String, |
| 355 | message_id: String, |
| 356 | }, |
| 357 | } |
| 358 | |
| 359 | async fn handle_message_event( |
| 360 | engine: Arc<Engine>, |
| 361 | nudge: mpsc::UnboundedSender<()>, |
| 362 | event: MessageEvent, |
| 363 | ) { |
| 364 | let Some(plan) = refresh_plan(&event) else { |
| 365 | return; |
| 366 | }; |
| 367 | let outcome = match &plan { |
| 368 | RefreshPlan::Newer { conversation_id } => { |
| 369 | engine.fetch_newer(conversation_id).await.map(|_| ()) |
| 370 | } |
| 371 | RefreshPlan::Message { |
| 372 | conversation_id, |
| 373 | message_id, |
| 374 | } => engine |
| 375 | .refresh_message(conversation_id, message_id) |
| 376 | .await |
| 377 | .map(|_| ()), |
| 378 | }; |
| 379 | let unknown = matches!(outcome, Err(teams_core::Error::UnknownConversation(_))); |
| 380 | if unknown || event.kind == EventKind::NewMessage { |
| 381 | let _ = nudge.send(()); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | async fn calendar_loop(session: Session, events: EventSender) { |
| 386 | let calendar = Calendar::new(&session); |
| 387 | let (nudge, mut nudges) = mpsc::unbounded_channel(); |
| 388 | let _ = events.send(BackendEvent::CalendarNudge(nudge)); |
| 389 | let mut interval = tokio::time::interval(CALENDAR_INTERVAL); |
| 390 | let mut last_fetch: Option<tokio::time::Instant> = None; |
| 391 | let mut deferred_fetch: Option<tokio::time::Instant> = None; |
| 392 | loop { |
| 393 | tokio::select! { |
| 394 | _ = interval.tick() => {} |
| 395 | _ = tokio::time::sleep_until(deferred_fetch.unwrap_or_else(tokio::time::Instant::now)), if deferred_fetch.is_some() => {} |
| 396 | nudge = nudges.recv() => { |
| 397 | if nudge.is_none() { |
| 398 | return; |
| 399 | } |
| 400 | while nudges.try_recv().is_ok() {} |
| 401 | if let Some(fetched) = last_fetch.filter(|fetched| fetched.elapsed() < CALENDAR_MIN_GAP) { |
| 402 | deferred_fetch = Some(fetched + CALENDAR_MIN_GAP); |
| 403 | continue; |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | deferred_fetch = None; |
| 408 | last_fetch = Some(tokio::time::Instant::now()); |
| 409 | let (start, end) = fetch_window(Utc::now(), Local::now().offset().fix()); |
| 410 | match calendar.calendar_view(start, end).await { |
| 411 | Ok(fetched) => { |
| 412 | if events.send(BackendEvent::Calendar(fetched)).is_err() { |
| 413 | return; |
| 414 | } |
| 415 | } |
| 416 | Err(error) => crate::diagnostics::record(format!( |
| 417 | "calls: calendar not loaded: {}", |
| 418 | shorten(&error.to_string()) |
| 419 | )), |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | async fn pins_loop(session: Session, events: EventSender) { |
| 425 | let pins = Pins::new(&session); |
| 426 | let mut chat_ids: Vec<String> = Vec::new(); |
| 427 | let mut channel_ids: Vec<String> = Vec::new(); |
| 428 | let mut interval = tokio::time::interval(PINS_INTERVAL); |
| 429 | loop { |
| 430 | interval.tick().await; |
| 431 | if let Ok(pinned) = pins.pinned_chats().await { |
| 432 | chat_ids = pinned.chat_ids; |
| 433 | } |
| 434 | if let Ok(pinned) = pins.pinned_channels().await { |
| 435 | channel_ids = pinned.channel_ids; |
| 436 | } |
| 437 | let combined = chat_ids.iter().chain(channel_ids.iter()).cloned().collect(); |
| 438 | if events.send(BackendEvent::Favorites(combined)).is_err() { |
| 439 | return; |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | #[cfg(test)] |
| 445 | mod tests { |
| 446 | use super::*; |
| 447 | |
| 448 | fn event(kind: EventKind, conversation: Option<&str>, message: Option<&str>) -> MessageEvent { |
| 449 | MessageEvent { |
| 450 | resource_type: "x".into(), |
| 451 | kind, |
| 452 | conversation_id: conversation.map(str::to_owned), |
| 453 | message_id: message.map(str::to_owned), |
| 454 | received_at: Utc::now(), |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | #[test] |
| 459 | fn new_message_fetches_newer() { |
| 460 | assert_eq!( |
| 461 | refresh_plan(&event(EventKind::NewMessage, Some("c"), Some("m"))), |
| 462 | Some(RefreshPlan::Newer { |
| 463 | conversation_id: "c".into() |
| 464 | }) |
| 465 | ); |
| 466 | } |
| 467 | |
| 468 | #[test] |
| 469 | fn update_refreshes_one_message() { |
| 470 | assert_eq!( |
| 471 | refresh_plan(&event(EventKind::MessageUpdate, Some("c"), Some("m"))), |
| 472 | Some(RefreshPlan::Message { |
| 473 | conversation_id: "c".into(), |
| 474 | message_id: "m".into() |
| 475 | }) |
| 476 | ); |
| 477 | assert_eq!( |
| 478 | refresh_plan(&event(EventKind::MessageUpdate, Some("c"), None)), |
| 479 | Some(RefreshPlan::Newer { |
| 480 | conversation_id: "c".into() |
| 481 | }) |
| 482 | ); |
| 483 | } |
| 484 | |
| 485 | #[test] |
| 486 | fn thread_updates_and_new_messages_signal_a_possible_meeting_change() { |
| 487 | assert_eq!( |
| 488 | thread_signal(&event(EventKind::ThreadUpdate, Some("c"), None)).as_deref(), |
| 489 | Some("c") |
| 490 | ); |
| 491 | assert_eq!( |
| 492 | thread_signal(&event(EventKind::NewMessage, Some("c"), Some("m"))).as_deref(), |
| 493 | Some("c") |
| 494 | ); |
| 495 | assert_eq!( |
| 496 | thread_signal(&event(EventKind::Typing, Some("c"), None)), |
| 497 | None |
| 498 | ); |
| 499 | assert_eq!( |
| 500 | thread_signal(&event(EventKind::ThreadUpdate, None, None)), |
| 501 | None |
| 502 | ); |
| 503 | } |
| 504 | |
| 505 | #[test] |
| 506 | fn typing_and_missing_conversation_are_ignored() { |
| 507 | assert_eq!( |
| 508 | refresh_plan(&event(EventKind::Typing, Some("c"), None)), |
| 509 | None |
| 510 | ); |
| 511 | assert_eq!( |
| 512 | refresh_plan(&event(EventKind::NewMessage, None, None)), |
| 513 | None |
| 514 | ); |
| 515 | } |
| 516 | |
| 517 | #[test] |
| 518 | fn session_errors_map_to_states() { |
| 519 | assert_eq!( |
| 520 | classify_session_error(&session::Error::NoAppTab), |
| 521 | ConnectionState::NoAppTab |
| 522 | ); |
| 523 | assert_eq!( |
| 524 | classify_session_error(&session::Error::LoginRequired("x".into())), |
| 525 | ConnectionState::LoginRequired |
| 526 | ); |
| 527 | assert_eq!(live_state_for(StatusKind::Connected), LiveState::Live); |
| 528 | } |
| 529 | |
| 530 | #[test] |
| 531 | fn only_connect_and_disconnect_move_the_link() { |
| 532 | assert_eq!( |
| 533 | link_signal_for(StatusKind::Connected), |
| 534 | Some(LinkSignal::Connected) |
| 535 | ); |
| 536 | assert_eq!( |
| 537 | link_signal_for(StatusKind::Disconnected), |
| 538 | Some(LinkSignal::Disconnected) |
| 539 | ); |
| 540 | assert_eq!(link_signal_for(StatusKind::MessageLoss), None); |
| 541 | assert_eq!(link_signal_for(StatusKind::Error), None); |
| 542 | } |
| 543 | } |