BlueGit

ict rusty-teams

fix(chat): writes to the notes chat without a Graph chat lookup

- resolve 48:notes as a chat directly; Graph GET /chats/48:notes answers 400 "not a ChatThread"
- no share invite for files sent to the notes chat
- Fake remote answers the notes lookup like Graph; engine test covers send, reply, edit, reactions, file, delete
- notes_send_probe example: engine send, edit, reactions, delete on 48:notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
7012743ab951aa5bce2072c18730dd109109e966
Parent
2bad9beb
4 files changed +218 −6
crates/core/examples/notes_send_probe.rs added +109 −0
@@ -0,0 +1,109 @@
1 use std::sync::Arc;
2 use std::time::Duration;
3
4 use graph::{Graph, MessageExtras};
5 use serde_json::Value;
6 use session::{DEFAULT_ENDPOINT, IC3, Request, Scope, Session};
7 use store::Store;
8 use teams_core::{NOTES_CHAT_ID, SyncEngine};
9
10 #[tokio::main]
11 async fn main() {
12 let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());
13 let session = Session::connect(&endpoint).await.expect("browser");
14 let engine = SyncEngine::new(
15 Graph::new(session.clone()),
16 Arc::new(Store::open_in_memory().unwrap()),
17 );
18
19 let sent = engine
20 .send_message_with_extras(
21 NOTES_CHAT_ID,
22 "<p>rusty-teams notes send probe</p>",
23 None,
24 &[],
25 &MessageExtras::default(),
26 )
27 .await
28 .expect("engine send to 48:notes");
29 let message_id = sent.message_id.clone();
30 println!("# engine send ok, id {message_id}");
31
32 tokio::time::sleep(Duration::from_secs(2)).await;
33 report(&session, &message_id, "after send").await;
34
35 let edit = engine
36 .edit_message_html(
37 NOTES_CHAT_ID,
38 &message_id,
39 "<p>rusty-teams notes probe edited</p>",
40 &[],
41 )
42 .await;
43 println!("# engine edit: {}", outcome(&edit));
44 let reaction = engine
45 .set_reaction(NOTES_CHAT_ID, &message_id, "\u{1f44d}")
46 .await;
47 println!("# engine set reaction: {}", outcome(&reaction));
48 let removal = engine
49 .unset_reaction(NOTES_CHAT_ID, &message_id, "\u{1f44d}")
50 .await;
51 println!("# engine unset reaction: {}", outcome(&removal));
52 tokio::time::sleep(Duration::from_secs(2)).await;
53 report(&session, &message_id, "after edit and reactions").await;
54
55 let deletion = engine.soft_delete_message(NOTES_CHAT_ID, &message_id).await;
56 println!("# engine delete: {}", outcome(&deletion));
57 tokio::time::sleep(Duration::from_secs(2)).await;
58 report(&session, &message_id, "after delete").await;
59 }
60
61 fn outcome<T>(result: &teams_core::Result<T>) -> String {
62 match result {
63 Ok(_) => "ok".to_owned(),
64 Err(error) => format!("error {error}"),
65 }
66 }
67
68 async fn report(session: &Session, message_id: &str, label: &str) {
69 let url = "https://teams.cloud.microsoft/api/chatsvc/emea/v1/users/ME/conversations/48%3Anotes/messages?view=msnp24Equivalent%7CsupportsMessageProperties&pageSize=20&startTime=1";
70 let scope = Scope::new(IC3, "Teams.AccessAsUser.All");
71 let answer = session
72 .batch(&[Request::get(url)], &scope)
73 .await
74 .expect("chatsvc")
75 .remove(0);
76 let found = answer
77 .body
78 .get("messages")
79 .and_then(Value::as_array)
80 .into_iter()
81 .flatten()
82 .find(|message| message.get("id").and_then(Value::as_str) == Some(message_id))
83 .cloned();
84 let Some(message) = found else {
85 println!(
86 "# {label}: not in chatsvc listing (status {})",
87 answer.status
88 );
89 return;
90 };
91 let text = |pointer: &str| {
92 message
93 .pointer(pointer)
94 .map(|value| {
95 value
96 .as_str()
97 .map(str::to_owned)
98 .unwrap_or_else(|| value.to_string())
99 })
100 .unwrap_or_else(|| "-".to_owned())
101 };
102 println!(
103 "# {label}: content={} edittime={} deletetime={} emotions={}",
104 text("/content"),
105 text("/properties/edittime"),
106 text("/properties/deletetime"),
107 text("/properties/emotions"),
108 );
109 }
@@ -0,0 +1,109 @@
1use std::sync::Arc;
2use std::time::Duration;
3
4use graph::{Graph, MessageExtras};
5use serde_json::Value;
6use session::{DEFAULT_ENDPOINT, IC3, Request, Scope, Session};
7use store::Store;
8use teams_core::{NOTES_CHAT_ID, SyncEngine};
9
10#[tokio::main]
11async fn main() {
12 let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());
13 let session = Session::connect(&endpoint).await.expect("browser");
14 let engine = SyncEngine::new(
15 Graph::new(session.clone()),
16 Arc::new(Store::open_in_memory().unwrap()),
17 );
18
19 let sent = engine
20 .send_message_with_extras(
21 NOTES_CHAT_ID,
22 "<p>rusty-teams notes send probe</p>",
23 None,
24 &[],
25 &MessageExtras::default(),
26 )
27 .await
28 .expect("engine send to 48:notes");
29 let message_id = sent.message_id.clone();
30 println!("# engine send ok, id {message_id}");
31
32 tokio::time::sleep(Duration::from_secs(2)).await;
33 report(&session, &message_id, "after send").await;
34
35 let edit = engine
36 .edit_message_html(
37 NOTES_CHAT_ID,
38 &message_id,
39 "<p>rusty-teams notes probe edited</p>",
40 &[],
41 )
42 .await;
43 println!("# engine edit: {}", outcome(&edit));
44 let reaction = engine
45 .set_reaction(NOTES_CHAT_ID, &message_id, "\u{1f44d}")
46 .await;
47 println!("# engine set reaction: {}", outcome(&reaction));
48 let removal = engine
49 .unset_reaction(NOTES_CHAT_ID, &message_id, "\u{1f44d}")
50 .await;
51 println!("# engine unset reaction: {}", outcome(&removal));
52 tokio::time::sleep(Duration::from_secs(2)).await;
53 report(&session, &message_id, "after edit and reactions").await;
54
55 let deletion = engine.soft_delete_message(NOTES_CHAT_ID, &message_id).await;
56 println!("# engine delete: {}", outcome(&deletion));
57 tokio::time::sleep(Duration::from_secs(2)).await;
58 report(&session, &message_id, "after delete").await;
59}
60
61fn outcome<T>(result: &teams_core::Result<T>) -> String {
62 match result {
63 Ok(_) => "ok".to_owned(),
64 Err(error) => format!("error {error}"),
65 }
66}
67
68async fn report(session: &Session, message_id: &str, label: &str) {
69 let url = "https://teams.cloud.microsoft/api/chatsvc/emea/v1/users/ME/conversations/48%3Anotes/messages?view=msnp24Equivalent%7CsupportsMessageProperties&pageSize=20&startTime=1";
70 let scope = Scope::new(IC3, "Teams.AccessAsUser.All");
71 let answer = session
72 .batch(&[Request::get(url)], &scope)
73 .await
74 .expect("chatsvc")
75 .remove(0);
76 let found = answer
77 .body
78 .get("messages")
79 .and_then(Value::as_array)
80 .into_iter()
81 .flatten()
82 .find(|message| message.get("id").and_then(Value::as_str) == Some(message_id))
83 .cloned();
84 let Some(message) = found else {
85 println!(
86 "# {label}: not in chatsvc listing (status {})",
87 answer.status
88 );
89 return;
90 };
91 let text = |pointer: &str| {
92 message
93 .pointer(pointer)
94 .map(|value| {
95 value
96 .as_str()
97 .map(str::to_owned)
98 .unwrap_or_else(|| value.to_string())
99 })
100 .unwrap_or_else(|| "-".to_owned())
101 };
102 println!(
103 "# {label}: content={} edittime={} deletetime={} emotions={}",
104 text("/content"),
105 text("/properties/edittime"),
106 text("/properties/deletetime"),
107 text("/properties/emotions"),
108 );
109}
crates/core/src/actions.rs +4 −0
@@ -14,6 +14,7 @@ use crate::mapping::message_record;
14 14 use crate::markdown::markdown_to_html;
15 15 use crate::mentions::{MentionInput, apply_mentions, ensure_allowed_in_chat};
16 16 use crate::remote::Remote;
17 use crate::scheduled::NOTES_CHAT_ID;
17 18
18 19 impl<R: Remote> SyncEngine<R> {
19 20 pub async fn send_message(
@@ -295,6 +296,9 @@ impl<R: Remote> SyncEngine<R> {
295 296 }
296 297
297 298 async fn other_member_ids(&self, chat_id: &str) -> Result<Vec<String>> {
299 if chat_id == NOTES_CHAT_ID {
300 return Ok(Vec::new());
301 }
298 302 let my_user_id = self.my_user_id().await?;
299 303 let members = self
300 304 .store
@@ -14,6 +14,7 @@ use crate::mapping::message_record;
14use crate::markdown::markdown_to_html;
14use crate::markdown::markdown_to_html;
15use crate::mentions::{MentionInput, apply_mentions, ensure_allowed_in_chat};
15use crate::mentions::{MentionInput, apply_mentions, ensure_allowed_in_chat};
16use crate::remote::Remote;
16use crate::remote::Remote;
17use crate::scheduled::NOTES_CHAT_ID;
17
18
18impl<R: Remote> SyncEngine<R> {
19impl<R: Remote> SyncEngine<R> {
19 pub async fn send_message(
20 pub async fn send_message(
@@ -295,6 +296,9 @@ impl<R: Remote> SyncEngine<R> {
295 }
296 }
296
297
297 async fn other_member_ids(&self, chat_id: &str) -> Result<Vec<String>> {
298 async fn other_member_ids(&self, chat_id: &str) -> Result<Vec<String>> {
299 if chat_id == NOTES_CHAT_ID {
300 return Ok(Vec::new());
301 }
298 let my_user_id = self.my_user_id().await?;
302 let my_user_id = self.my_user_id().await?;
299 let members = self
303 let members = self
300 .store
304 .store
crates/core/src/engine.rs +4 −0
@@ -19,6 +19,7 @@ use crate::presence::Presence;
19 19 use crate::preview::OwnedPreview;
20 20 use crate::receipts::ReceiptCache;
21 21 use crate::remote::{Remote, RemotePage};
22 use crate::scheduled::NOTES_CHAT_ID;
22 23
23 24 const EVENT_CAPACITY: usize = 64;
24 25 pub(crate) const META_USER_ID: &str = "me_user_id";
@@ -393,6 +394,9 @@ impl<R: Remote> SyncEngine<R> {
393 394 }
394 395
395 396 pub(crate) fn resolve_stored(&self, conversation_id: &str) -> Result<Conversation> {
397 if conversation_id == NOTES_CHAT_ID {
398 return Ok(Conversation::Chat);
399 }
396 400 if let Some(channel) = self.store.channel(conversation_id)? {
397 401 return Ok(Conversation::Channel {
398 402 team_id: channel.team_id,
@@ -19,6 +19,7 @@ use crate::presence::Presence;
19use crate::preview::OwnedPreview;
19use crate::preview::OwnedPreview;
20use crate::receipts::ReceiptCache;
20use crate::receipts::ReceiptCache;
21use crate::remote::{Remote, RemotePage};
21use crate::remote::{Remote, RemotePage};
22use crate::scheduled::NOTES_CHAT_ID;
22
23
23const EVENT_CAPACITY: usize = 64;
24const EVENT_CAPACITY: usize = 64;
24pub(crate) const META_USER_ID: &str = "me_user_id";
25pub(crate) const META_USER_ID: &str = "me_user_id";
@@ -393,6 +394,9 @@ impl<R: Remote> SyncEngine<R> {
393 }
394 }
394
395
395 pub(crate) fn resolve_stored(&self, conversation_id: &str) -> Result<Conversation> {
396 pub(crate) fn resolve_stored(&self, conversation_id: &str) -> Result<Conversation> {
397 if conversation_id == NOTES_CHAT_ID {
398 return Ok(Conversation::Chat);
399 }
396 if let Some(channel) = self.store.channel(conversation_id)? {
400 if let Some(channel) = self.store.channel(conversation_id)? {
397 return Ok(Conversation::Channel {
401 return Ok(Conversation::Channel {
398 team_id: channel.team_id,
402 team_id: channel.team_id,
crates/core/tests/engine.rs +101 −6
@@ -14,7 +14,7 @@ use store::{
14 14 use teams_core::{
15 15 Availability, BoxFuture, ChatFolder, ChatSection, ChatSectionSettings, ChatsPage, CoreEvent,
16 16 DeltaPage, Error, FolderChange, FolderKind, FolderSource, MentionCandidate, MentionInput,
17 MentionTarget, PersonSource, Remote, RemotePage, Result, SyncConfig, SyncEngine,
17 MentionTarget, NOTES_CHAT_ID, PersonSource, Remote, RemotePage, Result, SyncConfig, SyncEngine,
18 18 substrate_search,
19 19 };
20 20
@@ -231,6 +231,13 @@ impl Remote for Handle {
231 231
232 232 async fn chat(&self, chat_id: &str) -> Result<Chat> {
233 233 *self.single_chat_calls.lock().unwrap() += 1;
234 if chat_id == NOTES_CHAT_ID {
235 return Err(Error::Graph(graph::Error::Session(session::Error::api(
236 400,
237 chat_id,
238 json!({"error": {"code": "BadRequest", "message": "Resource is not a ChatThread"}}),
239 ))));
240 }
234 241 let found = self
235 242 .fetchable_chats
236 243 .lock()
@@ -2212,6 +2219,79 @@ async fn upload_to_an_unknown_conversation_fails() {
2212 2219 );
2213 2220 }
2214 2221
2222 #[tokio::test]
2223 async fn the_notes_chat_takes_every_write_without_a_graph_chat_lookup() {
2224 let fake = Arc::new(Fake::default());
2225 let engine = chat_engine(&fake, small_pages()).await;
2226 let extras = MessageExtras {
2227 kept: Vec::new(),
2228 images: vec![HostedImage {
2229 content_type: "image/png".into(),
2230 bytes: Arc::new(vec![9]),
2231 }],
2232 files: Vec::new(),
2233 };
2234
2235 let sent = engine
2236 .send_message_with_extras(NOTES_CHAT_ID, "note to self", None, &[], &extras)
2237 .await
2238 .unwrap();
2239 fake.set_chat_messages(vec![message(9000, 500, "<p>note to self</p>")]);
2240 engine
2241 .reply_to_with_extras(
2242 NOTES_CHAT_ID,
2243 &sent.message_id,
2244 "again",
2245 &[],
2246 &MessageExtras::default(),
2247 )
2248 .await
2249 .unwrap();
2250 engine
2251 .edit_message_html(NOTES_CHAT_ID, &sent.message_id, "edited", &[])
2252 .await
2253 .unwrap();
2254 engine
2255 .set_reaction(NOTES_CHAT_ID, &sent.message_id, "\u{1f44d}")
2256 .await
2257 .unwrap();
2258 engine
2259 .unset_reaction(NOTES_CHAT_ID, &sent.message_id, "\u{1f44d}")
2260 .await
2261 .unwrap();
2262 engine
2263 .upload_attachment(NOTES_CHAT_ID, "plan.txt", b"plan", |_| {})
2264 .await
2265 .unwrap();
2266 engine
2267 .soft_delete_message(NOTES_CHAT_ID, &sent.message_id)
2268 .await
2269 .unwrap();
2270
2271 assert_eq!(*fake.single_chat_calls.lock().unwrap(), 0);
2272 assert_eq!(fake.sent.lock().unwrap().as_slice(), ["note to self"]);
2273 let calls = fake.calls();
2274 for expected in [
2275 "quote_reply 48:notes m9000 again",
2276 "edit m9000 edited",
2277 "set_reaction m9000 \u{1f44d}",
2278 "unset_reaction m9000 \u{1f44d}",
2279 "upload chat-files plan.txt 4",
2280 "soft_delete user-me m9000",
2281 ] {
2282 assert!(
2283 calls.iter().any(|call| call == expected),
2284 "{expected} in {calls:?}"
2285 );
2286 }
2287 assert!(
2288 calls
2289 .iter()
2290 .any(|call| call.starts_with("share ") && call.ends_with(' ')),
2291 "{calls:?}"
2292 );
2293 }
2294
2215 2295 #[tokio::test]
2216 2296 async fn send_with_extras_hands_images_and_files_to_the_remote() {
2217 2297 let fake = Arc::new(Fake::default());
@@ -4815,7 +4895,11 @@ fn forwarded_message_without_original(id: &str, minute: i64) -> Message {
4815 4895 message
4816 4896 }
4817 4897
4818 fn forward_state(store: &Store, conversation_id: &str, message_id: &str) -> teams_core::ForwardState {
4898 fn forward_state(
4899 store: &Store,
4900 conversation_id: &str,
4901 message_id: &str,
4902 ) -> teams_core::ForwardState {
4819 4903 let record = store
4820 4904 .messages_by_id(conversation_id, &[message_id.to_owned()])
4821 4905 .unwrap()
@@ -4834,12 +4918,20 @@ async fn a_forward_graph_returns_without_its_original_is_not_read_again() {
4834 4918 let mut messages = numbered(11);
4835 4919 messages.push(forwarded_message_without_original("m0000", 0));
4836 4920 fake.set_chat_messages(messages);
4837 store.upsert_messages(&[stale_forward(CHAT, "m0000", 0)]).unwrap();
4838 assert_eq!(forward_state(&store, CHAT, "m0000"), teams_core::ForwardState::Loading);
4921 store
4922 .upsert_messages(&[stale_forward(CHAT, "m0000", 0)])
4923 .unwrap();
4924 assert_eq!(
4925 forward_state(&store, CHAT, "m0000"),
4926 teams_core::ForwardState::Loading
4927 );
4839 4928
4840 4929 engine.fetch_newer(CHAT).await.unwrap();
4841 4930
4842 assert_eq!(forward_state(&store, CHAT, "m0000"), teams_core::ForwardState::Unavailable);
4931 assert_eq!(
4932 forward_state(&store, CHAT, "m0000"),
4933 teams_core::ForwardState::Unavailable
4934 );
4843 4935 let next_session = SyncEngine::with_config(Handle(fake.clone()), store.clone(), small_pages());
4844 4936 next_session.fetch_newer(CHAT).await.unwrap();
4845 4937 let reads = fake
@@ -4885,7 +4977,10 @@ async fn the_background_heal_reads_the_newest_chat_first_and_skips_healthy_chats
4885 4977 .filter(|call| call.starts_with("chat_message "))
4886 4978 .collect();
4887 4979 assert_eq!(reads, ["chat_message f-newer", "chat_message f-older"]);
4888 assert_eq!(forward_state(&store, OLDER, "f-older"), teams_core::ForwardState::Ready);
4980 assert_eq!(
4981 forward_state(&store, OLDER, "f-older"),
4982 teams_core::ForwardState::Ready
4983 );
4889 4984 let mut changed = Vec::new();
4890 4985 while let Ok(event) = events.try_recv() {
4891 4986 if let CoreEvent::MessagesChanged { conversation_id } = event {
@@ -14,7 +14,7 @@ use store::{
14use teams_core::{
14use teams_core::{
15 Availability, BoxFuture, ChatFolder, ChatSection, ChatSectionSettings, ChatsPage, CoreEvent,
15 Availability, BoxFuture, ChatFolder, ChatSection, ChatSectionSettings, ChatsPage, CoreEvent,
16 DeltaPage, Error, FolderChange, FolderKind, FolderSource, MentionCandidate, MentionInput,
16 DeltaPage, Error, FolderChange, FolderKind, FolderSource, MentionCandidate, MentionInput,
17 MentionTarget, PersonSource, Remote, RemotePage, Result, SyncConfig, SyncEngine,
17 MentionTarget, NOTES_CHAT_ID, PersonSource, Remote, RemotePage, Result, SyncConfig, SyncEngine,
18 substrate_search,
18 substrate_search,
19};
19};
20
20
@@ -231,6 +231,13 @@ impl Remote for Handle {
231
231
232 async fn chat(&self, chat_id: &str) -> Result<Chat> {
232 async fn chat(&self, chat_id: &str) -> Result<Chat> {
233 *self.single_chat_calls.lock().unwrap() += 1;
233 *self.single_chat_calls.lock().unwrap() += 1;
234 if chat_id == NOTES_CHAT_ID {
235 return Err(Error::Graph(graph::Error::Session(session::Error::api(
236 400,
237 chat_id,
238 json!({"error": {"code": "BadRequest", "message": "Resource is not a ChatThread"}}),
239 ))));
240 }
234 let found = self
241 let found = self
235 .fetchable_chats
242 .fetchable_chats
236 .lock()
243 .lock()
@@ -2212,6 +2219,79 @@ async fn upload_to_an_unknown_conversation_fails() {
2212 );
2219 );
2213}
2220}
2214
2221
2222#[tokio::test]
2223async fn the_notes_chat_takes_every_write_without_a_graph_chat_lookup() {
2224 let fake = Arc::new(Fake::default());
2225 let engine = chat_engine(&fake, small_pages()).await;
2226 let extras = MessageExtras {
2227 kept: Vec::new(),
2228 images: vec![HostedImage {
2229 content_type: "image/png".into(),
2230 bytes: Arc::new(vec![9]),
2231 }],
2232 files: Vec::new(),
2233 };
2234
2235 let sent = engine
2236 .send_message_with_extras(NOTES_CHAT_ID, "note to self", None, &[], &extras)
2237 .await
2238 .unwrap();
2239 fake.set_chat_messages(vec![message(9000, 500, "<p>note to self</p>")]);
2240 engine
2241 .reply_to_with_extras(
2242 NOTES_CHAT_ID,
2243 &sent.message_id,
2244 "again",
2245 &[],
2246 &MessageExtras::default(),
2247 )
2248 .await
2249 .unwrap();
2250 engine
2251 .edit_message_html(NOTES_CHAT_ID, &sent.message_id, "edited", &[])
2252 .await
2253 .unwrap();
2254 engine
2255 .set_reaction(NOTES_CHAT_ID, &sent.message_id, "\u{1f44d}")
2256 .await
2257 .unwrap();
2258 engine
2259 .unset_reaction(NOTES_CHAT_ID, &sent.message_id, "\u{1f44d}")
2260 .await
2261 .unwrap();
2262 engine
2263 .upload_attachment(NOTES_CHAT_ID, "plan.txt", b"plan", |_| {})
2264 .await
2265 .unwrap();
2266 engine
2267 .soft_delete_message(NOTES_CHAT_ID, &sent.message_id)
2268 .await
2269 .unwrap();
2270
2271 assert_eq!(*fake.single_chat_calls.lock().unwrap(), 0);
2272 assert_eq!(fake.sent.lock().unwrap().as_slice(), ["note to self"]);
2273 let calls = fake.calls();
2274 for expected in [
2275 "quote_reply 48:notes m9000 again",
2276 "edit m9000 edited",
2277 "set_reaction m9000 \u{1f44d}",
2278 "unset_reaction m9000 \u{1f44d}",
2279 "upload chat-files plan.txt 4",
2280 "soft_delete user-me m9000",
2281 ] {
2282 assert!(
2283 calls.iter().any(|call| call == expected),
2284 "{expected} in {calls:?}"
2285 );
2286 }
2287 assert!(
2288 calls
2289 .iter()
2290 .any(|call| call.starts_with("share ") && call.ends_with(' ')),
2291 "{calls:?}"
2292 );
2293}
2294
2215#[tokio::test]
2295#[tokio::test]
2216async fn send_with_extras_hands_images_and_files_to_the_remote() {
2296async fn send_with_extras_hands_images_and_files_to_the_remote() {
2217 let fake = Arc::new(Fake::default());
2297 let fake = Arc::new(Fake::default());
@@ -4815,7 +4895,11 @@ fn forwarded_message_without_original(id: &str, minute: i64) -> Message {
4815 message
4895 message
4816}
4896}
4817
4897
4818fn forward_state(store: &Store, conversation_id: &str, message_id: &str) -> teams_core::ForwardState {
4898fn forward_state(
4899 store: &Store,
4900 conversation_id: &str,
4901 message_id: &str,
4902) -> teams_core::ForwardState {
4819 let record = store
4903 let record = store
4820 .messages_by_id(conversation_id, &[message_id.to_owned()])
4904 .messages_by_id(conversation_id, &[message_id.to_owned()])
4821 .unwrap()
4905 .unwrap()
@@ -4834,12 +4918,20 @@ async fn a_forward_graph_returns_without_its_original_is_not_read_again() {
4834 let mut messages = numbered(11);
4918 let mut messages = numbered(11);
4835 messages.push(forwarded_message_without_original("m0000", 0));
4919 messages.push(forwarded_message_without_original("m0000", 0));
4836 fake.set_chat_messages(messages);
4920 fake.set_chat_messages(messages);
4837 store.upsert_messages(&[stale_forward(CHAT, "m0000", 0)]).unwrap();
4921 store
4838 assert_eq!(forward_state(&store, CHAT, "m0000"), teams_core::ForwardState::Loading);
4922 .upsert_messages(&[stale_forward(CHAT, "m0000", 0)])
4923 .unwrap();
4924 assert_eq!(
4925 forward_state(&store, CHAT, "m0000"),
4926 teams_core::ForwardState::Loading
4927 );
4839
4928
4840 engine.fetch_newer(CHAT).await.unwrap();
4929 engine.fetch_newer(CHAT).await.unwrap();
4841
4930
4842 assert_eq!(forward_state(&store, CHAT, "m0000"), teams_core::ForwardState::Unavailable);
4931 assert_eq!(
4932 forward_state(&store, CHAT, "m0000"),
4933 teams_core::ForwardState::Unavailable
4934 );
4843 let next_session = SyncEngine::with_config(Handle(fake.clone()), store.clone(), small_pages());
4935 let next_session = SyncEngine::with_config(Handle(fake.clone()), store.clone(), small_pages());
4844 next_session.fetch_newer(CHAT).await.unwrap();
4936 next_session.fetch_newer(CHAT).await.unwrap();
4845 let reads = fake
4937 let reads = fake
@@ -4885,7 +4977,10 @@ async fn the_background_heal_reads_the_newest_chat_first_and_skips_healthy_chats
4885 .filter(|call| call.starts_with("chat_message "))
4977 .filter(|call| call.starts_with("chat_message "))
4886 .collect();
4978 .collect();
4887 assert_eq!(reads, ["chat_message f-newer", "chat_message f-older"]);
4979 assert_eq!(reads, ["chat_message f-newer", "chat_message f-older"]);
4888 assert_eq!(forward_state(&store, OLDER, "f-older"), teams_core::ForwardState::Ready);
4980 assert_eq!(
4981 forward_state(&store, OLDER, "f-older"),
4982 teams_core::ForwardState::Ready
4983 );
4889 let mut changed = Vec::new();
4984 let mut changed = Vec::new();
4890 while let Ok(event) = events.try_recv() {
4985 while let Ok(event) = events.try_recv() {
4891 if let CoreEvent::MessagesChanged { conversation_id } = event {
4986 if let CoreEvent::MessagesChanged { conversation_id } = event {