BlueGit

ict rusty-teams

Files

rusty-teams / crates / core / src / remote.rs

remote.rs

remote.rs 22.3 KiB Download Raw
1use chatsvc::{
2 CardActions, ChatApp, ConversationRef, Conversations, Gif, Gifs, InvokeRequest, InvokeResponse,
3 LinkInfo, MemberHorizon, MessageLinks, Messages, Receipts,
4};
5use chrono::{DateTime, Utc};
6use graph::{
7 Channel, Chat, DriveFolder, Graph, Member, Message, MessageExtras, MessageTarget,
8 OutgoingMention, Photo, Presence, SharedFile, Team, UploadDestination, UploadedFile, User,
9};
10
11use crate::error::{Error, Result};
12
13pub const CHATSVC_CHAT_WRITES: bool = false;
14
15#[derive(Debug, Clone)]
16pub struct RemotePage {
17 pub items: Vec<Message>,
18 pub next_link: Option<String>,
19}
20
21#[derive(Debug, Clone)]
22pub struct DeltaPage {
23 pub items: Vec<Message>,
24 pub next_link: Option<String>,
25 pub delta_link: Option<String>,
26}
27
28#[derive(Debug, Clone)]
29pub struct ChatsPage {
30 pub items: Vec<Chat>,
31 pub next_link: Option<String>,
32}
33
34#[allow(async_fn_in_trait)]
35pub trait Remote {
36 async fn me(&self) -> Result<User>;
37 async fn chats_page(&self, top: usize) -> Result<ChatsPage>;
38 async fn chats_at(&self, next_link: &str) -> Result<ChatsPage>;
39 async fn chat(&self, chat_id: &str) -> Result<Chat>;
40 async fn chat_members(&self, chat_id: &str) -> Result<Vec<Member>>;
41 async fn joined_teams(&self) -> Result<Vec<Team>>;
42 async fn channels_for_teams(&self, team_ids: &[String]) -> Result<Vec<Result<Vec<Channel>>>>;
43 async fn chat_messages(
44 &self,
45 chat_id: &str,
46 before: Option<DateTime<Utc>>,
47 top: usize,
48 ) -> Result<RemotePage>;
49 async fn chat_message(&self, chat_id: &str, message_id: &str) -> Result<Message>;
50 async fn channel_messages(
51 &self,
52 team_id: &str,
53 channel_id: &str,
54 top: usize,
55 ) -> Result<RemotePage>;
56 async fn channel_messages_at(&self, next_link: &str) -> Result<RemotePage>;
57 async fn channel_message(
58 &self,
59 team_id: &str,
60 channel_id: &str,
61 message_id: &str,
62 ) -> Result<Message>;
63 async fn channel_reply(
64 &self,
65 team_id: &str,
66 channel_id: &str,
67 message_id: &str,
68 reply_id: &str,
69 ) -> Result<Message>;
70 async fn channel_delta(
71 &self,
72 team_id: &str,
73 channel_id: &str,
74 modified_after: Option<DateTime<Utc>>,
75 ) -> Result<DeltaPage>;
76 async fn channel_delta_at(&self, link: &str) -> Result<DeltaPage>;
77 async fn channel_replies(
78 &self,
79 team_id: &str,
80 channel_id: &str,
81 root_ids: &[String],
82 ) -> Result<Vec<Result<Vec<Message>>>>;
83 async fn send_chat_message(
84 &self,
85 chat_id: &str,
86 html: &str,
87 mentions: &[OutgoingMention],
88 extras: &MessageExtras,
89 ) -> Result<Message>;
90 async fn send_channel_message(
91 &self,
92 team_id: &str,
93 channel_id: &str,
94 html: &str,
95 subject: Option<&str>,
96 mentions: &[OutgoingMention],
97 extras: &MessageExtras,
98 ) -> Result<Message>;
99 async fn reply_to_channel_message(
100 &self,
101 team_id: &str,
102 channel_id: &str,
103 message_id: &str,
104 html: &str,
105 mentions: &[OutgoingMention],
106 extras: &MessageExtras,
107 ) -> Result<Message>;
108 async fn mark_chat_read(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
109 async fn mark_chat_unread(
110 &self,
111 chat_id: &str,
112 user_id: &str,
113 tenant_id: &str,
114 last_read_at: DateTime<Utc>,
115 ) -> Result<()>;
116 async fn hide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
117 async fn unhide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
118 async fn leave_chat(&self, chat_id: &str, user_id: &str) -> Result<()>;
119 async fn muted_chat_states(&self) -> Result<Vec<(String, bool)>>;
120 async fn set_chat_muted(&self, chat_id: &str, muted: bool) -> Result<()>;
121 async fn send_typing(&self, conversation: &ConversationRef, active: bool) -> Result<()>;
122 async fn set_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()>;
123 async fn unset_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()>;
124 async fn edit_message(
125 &self,
126 target: &MessageTarget,
127 html: &str,
128 mentions: &[OutgoingMention],
129 extras: &MessageExtras,
130 ) -> Result<()>;
131 async fn soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()>;
132 async fn create_one_on_one(&self, my_user_id: &str, user_id: &str) -> Result<Chat>;
133 async fn create_group(
134 &self,
135 my_user_id: &str,
136 user_ids: &[String],
137 topic: Option<&str>,
138 ) -> Result<Chat>;
139 async fn search_people(&self, query: &str) -> Result<Vec<User>>;
140
141 async fn reply_with_quote(
142 &self,
143 _chat_id: &str,
144 _quoted_message_id: &str,
145 _html: &str,
146 _mentions: &[OutgoingMention],
147 _extras: &MessageExtras,
148 ) -> Result<Message> {
149 Err(Error::Unsupported("a quoted reply"))
150 }
151
152 async fn channel_files_folder(&self, _team_id: &str, _channel_id: &str) -> Result<DriveFolder> {
153 Err(Error::Unsupported("a channel files folder"))
154 }
155
156 async fn upload_file(
157 &self,
158 _destination: &UploadDestination,
159 _file_name: &str,
160 _bytes: &[u8],
161 _progress: &(dyn Fn(u8) + Send + Sync),
162 ) -> Result<UploadedFile> {
163 Err(Error::Unsupported("a file upload"))
164 }
165
166 async fn share_file(&self, _file: &UploadedFile, _user_ids: &[String]) -> Result<()> {
167 Err(Error::Unsupported("sharing a file"))
168 }
169
170 async fn delete_file(&self, _file: &UploadedFile) -> Result<()> {
171 Err(Error::Unsupported("deleting a file"))
172 }
173
174 async fn resolve_share(&self, _open_url: &str) -> Result<SharedFile> {
175 Err(Error::Unsupported("resolving a shared file"))
176 }
177
178 async fn download_range(
179 &self,
180 _download_url: &str,
181 _start: u64,
182 _end: Option<u64>,
183 ) -> Result<Vec<u8>> {
184 Err(Error::Unsupported("a file download"))
185 }
186
187 async fn hosted_content(&self, _url: &str) -> Result<Photo> {
188 Err(Error::Unsupported("hosted content"))
189 }
190
191 async fn external_image(&self, _url: &str) -> Result<Photo> {
192 Err(Error::Unsupported("external images"))
193 }
194
195 async fn user_photos(&self, _user_ids: &[String]) -> Result<Vec<Result<Option<Photo>>>> {
196 Err(Error::Unsupported("profile photos"))
197 }
198
199 async fn presences(&self, _user_ids: &[String]) -> Result<Vec<Presence>> {
200 Err(Error::Unsupported("presence"))
201 }
202
203 async fn subscribe_presence(
204 &self,
205 _endpoint_id: &str,
206 _trouter_uri: &str,
207 _user_ids: &[String],
208 _purge: bool,
209 ) -> Result<()> {
210 Err(Error::Unsupported("presence subscriptions"))
211 }
212
213 async fn consumption_horizons(&self, _conversation_id: &str) -> Result<Vec<MemberHorizon>> {
214 Err(Error::Unsupported("read receipts"))
215 }
216
217 async fn chat_apps(&self, _chat_id: &str) -> Result<Vec<ChatApp>> {
218 Err(Error::Unsupported("chat apps"))
219 }
220
221 async fn invoke_card(&self, _invoke: InvokeRequest) -> Result<InvokeResponse> {
222 Err(Error::Unsupported("card actions"))
223 }
224
225 async fn message_links(
226 &self,
227 _conversation: &ConversationRef,
228 _page_size: usize,
229 ) -> Result<Vec<MessageLinks>> {
230 Err(Error::Unsupported("link previews"))
231 }
232
233 async fn set_message_links(&self, _target: &MessageTarget, _links_json: &str) -> Result<()> {
234 Err(Error::Unsupported("link previews"))
235 }
236
237 async fn link_info(&self, _url: &str) -> Result<LinkInfo> {
238 Err(Error::Unsupported("link previews"))
239 }
240
241 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
242 Err(Error::Unsupported("GIF search"))
243 }
244}
245
246impl Remote for Graph {
247 async fn me(&self) -> Result<User> {
248 Ok(Graph::me(self).await?)
249 }
250
251 async fn chats_page(&self, top: usize) -> Result<ChatsPage> {
252 Ok(Graph::chats_page(self, top).await?.into())
253 }
254
255 async fn chats_at(&self, next_link: &str) -> Result<ChatsPage> {
256 Ok(Graph::chats_at(self, next_link).await?.into())
257 }
258
259 async fn chat(&self, chat_id: &str) -> Result<Chat> {
260 Ok(Graph::chat(self, chat_id).await?)
261 }
262
263 async fn chat_members(&self, chat_id: &str) -> Result<Vec<Member>> {
264 Ok(Graph::chat_members(self, chat_id).await?)
265 }
266
267 async fn joined_teams(&self) -> Result<Vec<Team>> {
268 Ok(Graph::joined_teams(self).await?)
269 }
270
271 async fn channels_for_teams(&self, team_ids: &[String]) -> Result<Vec<Result<Vec<Channel>>>> {
272 let listings = Graph::channels_for_teams(self, team_ids).await?;
273 Ok(listings
274 .into_iter()
275 .map(|listing| listing.map_err(Into::into))
276 .collect())
277 }
278
279 async fn chat_messages(
280 &self,
281 chat_id: &str,
282 before: Option<DateTime<Utc>>,
283 top: usize,
284 ) -> Result<RemotePage> {
285 Ok(Graph::chat_messages(self, chat_id, before, top)
286 .await?
287 .into())
288 }
289
290 async fn chat_message(&self, chat_id: &str, message_id: &str) -> Result<Message> {
291 Ok(Graph::chat_message(self, chat_id, message_id).await?)
292 }
293
294 async fn channel_messages(
295 &self,
296 team_id: &str,
297 channel_id: &str,
298 top: usize,
299 ) -> Result<RemotePage> {
300 Ok(Graph::channel_messages(self, team_id, channel_id, top)
301 .await?
302 .into())
303 }
304
305 async fn channel_messages_at(&self, next_link: &str) -> Result<RemotePage> {
306 Ok(Graph::channel_messages_at(self, next_link).await?.into())
307 }
308
309 async fn channel_message(
310 &self,
311 team_id: &str,
312 channel_id: &str,
313 message_id: &str,
314 ) -> Result<Message> {
315 Ok(Graph::channel_message(self, team_id, channel_id, message_id).await?)
316 }
317
318 async fn channel_reply(
319 &self,
320 team_id: &str,
321 channel_id: &str,
322 message_id: &str,
323 reply_id: &str,
324 ) -> Result<Message> {
325 Ok(Graph::channel_reply(self, team_id, channel_id, message_id, reply_id).await?)
326 }
327
328 async fn channel_delta(
329 &self,
330 team_id: &str,
331 channel_id: &str,
332 modified_after: Option<DateTime<Utc>>,
333 ) -> Result<DeltaPage> {
334 Ok(
335 Graph::channel_delta(self, team_id, channel_id, modified_after)
336 .await?
337 .into(),
338 )
339 }
340
341 async fn channel_delta_at(&self, link: &str) -> Result<DeltaPage> {
342 Ok(Graph::channel_delta_at(self, link).await?.into())
343 }
344
345 async fn channel_replies(
346 &self,
347 team_id: &str,
348 channel_id: &str,
349 root_ids: &[String],
350 ) -> Result<Vec<Result<Vec<Message>>>> {
351 let listings = Graph::channel_replies(self, team_id, channel_id, root_ids).await?;
352 Ok(listings
353 .into_iter()
354 .map(|listing| listing.map_err(Into::into))
355 .collect())
356 }
357
358 async fn send_chat_message(
359 &self,
360 chat_id: &str,
361 html: &str,
362 mentions: &[OutgoingMention],
363 extras: &MessageExtras,
364 ) -> Result<Message> {
365 Ok(Graph::send_chat_message(self, chat_id, html, mentions, extras).await?)
366 }
367
368 async fn send_channel_message(
369 &self,
370 team_id: &str,
371 channel_id: &str,
372 html: &str,
373 subject: Option<&str>,
374 mentions: &[OutgoingMention],
375 extras: &MessageExtras,
376 ) -> Result<Message> {
377 Ok(
378 Graph::send_channel_message(self, team_id, channel_id, html, subject, mentions, extras)
379 .await?,
380 )
381 }
382
383 async fn reply_to_channel_message(
384 &self,
385 team_id: &str,
386 channel_id: &str,
387 message_id: &str,
388 html: &str,
389 mentions: &[OutgoingMention],
390 extras: &MessageExtras,
391 ) -> Result<Message> {
392 Ok(Graph::reply_to_channel_message(
393 self, team_id, channel_id, message_id, html, mentions, extras,
394 )
395 .await?)
396 }
397
398 async fn mark_chat_read(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
399 Ok(Graph::mark_chat_read(self, chat_id, user_id, tenant_id).await?)
400 }
401
402 async fn mark_chat_unread(
403 &self,
404 chat_id: &str,
405 user_id: &str,
406 tenant_id: &str,
407 last_read_at: DateTime<Utc>,
408 ) -> Result<()> {
409 Ok(Graph::mark_chat_unread(self, chat_id, user_id, tenant_id, last_read_at).await?)
410 }
411
412 async fn hide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
413 Ok(Graph::hide_chat(self, chat_id, user_id, tenant_id).await?)
414 }
415
416 async fn unhide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
417 Ok(Graph::unhide_chat(self, chat_id, user_id, tenant_id).await?)
418 }
419
420 async fn leave_chat(&self, chat_id: &str, user_id: &str) -> Result<()> {
421 Ok(Graph::leave_chat(self, chat_id, user_id).await?)
422 }
423
424 async fn muted_chat_states(&self) -> Result<Vec<(String, bool)>> {
425 Ok(Conversations::new(self.session())
426 .conversation_mute_states()
427 .await?)
428 }
429
430 async fn set_chat_muted(&self, chat_id: &str, muted: bool) -> Result<()> {
431 Ok(Conversations::new(self.session())
432 .set_alerts(chat_id, !muted)
433 .await?)
434 }
435
436 async fn send_typing(&self, conversation: &ConversationRef, active: bool) -> Result<()> {
437 Ok(Messages::new(self.session())
438 .send_typing(conversation, active)
439 .await?)
440 }
441
442 async fn set_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
443 if let Some(key) = chatsvc::emotion_key(reaction_type) {
444 return Ok(Messages::new(self.session())
445 .set_emotion(&conversation_ref(target), target.message_id(), key)
446 .await?);
447 }
448 Ok(Graph::set_reaction(self, target, reaction_type).await?)
449 }
450
451 async fn unset_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
452 let keys = chatsvc::emotion_keys(reaction_type);
453 if !keys.is_empty() {
454 return Ok(Messages::new(self.session())
455 .unset_emotions(&conversation_ref(target), target.message_id(), keys)
456 .await?);
457 }
458 Ok(Graph::unset_reaction(self, target, reaction_type).await?)
459 }
460
461 async fn edit_message(
462 &self,
463 target: &MessageTarget,
464 html: &str,
465 mentions: &[OutgoingMention],
466 extras: &MessageExtras,
467 ) -> Result<()> {
468 match chatsvc_conversation(target) {
469 Some(conversation) if mentions.is_empty() => {
470 let html = format!("{}{html}{}", extras.kept_html(), extras.files_html());
471 Ok(Messages::new(self.session())
472 .edit_message(&conversation, target.message_id(), &html)
473 .await?)
474 }
475 Some(_) => Err(Error::Unsupported(
476 "editing a channel message with mentions",
477 )),
478 None => Ok(Graph::edit_message(self, target, html, mentions, extras).await?),
479 }
480 }
481
482 async fn soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()> {
483 match chatsvc_conversation(target) {
484 Some(conversation) => Ok(Messages::new(self.session())
485 .soft_delete_message(&conversation, target.message_id())
486 .await?),
487 None => Ok(Graph::soft_delete_message(self, user_id, target).await?),
488 }
489 }
490
491 async fn create_one_on_one(&self, my_user_id: &str, user_id: &str) -> Result<Chat> {
492 Ok(Graph::create_one_on_one(self, my_user_id, user_id).await?)
493 }
494
495 async fn create_group(
496 &self,
497 my_user_id: &str,
498 user_ids: &[String],
499 topic: Option<&str>,
500 ) -> Result<Chat> {
501 Ok(Graph::create_group(self, my_user_id, user_ids, topic).await?)
502 }
503
504 async fn search_people(&self, query: &str) -> Result<Vec<User>> {
505 Ok(Graph::search_people(self, query).await?)
506 }
507
508 async fn reply_with_quote(
509 &self,
510 chat_id: &str,
511 quoted_message_id: &str,
512 html: &str,
513 mentions: &[OutgoingMention],
514 extras: &MessageExtras,
515 ) -> Result<Message> {
516 Ok(
517 Graph::reply_with_quote(self, chat_id, quoted_message_id, html, mentions, extras)
518 .await?,
519 )
520 }
521
522 async fn channel_files_folder(&self, team_id: &str, channel_id: &str) -> Result<DriveFolder> {
523 Ok(Graph::channel_files_folder(self, team_id, channel_id).await?)
524 }
525
526 async fn upload_file(
527 &self,
528 destination: &UploadDestination,
529 file_name: &str,
530 bytes: &[u8],
531 progress: &(dyn Fn(u8) + Send + Sync),
532 ) -> Result<UploadedFile> {
533 Ok(Graph::upload_file(self, destination, file_name, bytes, progress).await?)
534 }
535
536 async fn share_file(&self, file: &UploadedFile, user_ids: &[String]) -> Result<()> {
537 Ok(Graph::share_item(self, file, user_ids).await?)
538 }
539
540 async fn delete_file(&self, file: &UploadedFile) -> Result<()> {
541 Ok(Graph::delete_drive_item(self, &file.drive_id, &file.item_id).await?)
542 }
543
544 async fn resolve_share(&self, open_url: &str) -> Result<SharedFile> {
545 Ok(Graph::resolve_share(self, open_url).await?)
546 }
547
548 async fn download_range(
549 &self,
550 download_url: &str,
551 start: u64,
552 end: Option<u64>,
553 ) -> Result<Vec<u8>> {
554 Ok(Graph::download_range(self, download_url, start, end).await?)
555 }
556
557 async fn hosted_content(&self, url: &str) -> Result<Photo> {
558 if chatsvc::is_link_image_url(url) {
559 let image = Messages::new(self.session()).link_image(url).await?;
560 return Ok(Photo {
561 bytes: image.bytes,
562 content_type: image.content_type,
563 });
564 }
565 Ok(Graph::download_hosted_content(self, url).await?)
566 }
567
568 async fn external_image(&self, url: &str) -> Result<Photo> {
569 Ok(Graph::download_external_image(self, url).await?)
570 }
571
572 async fn user_photos(&self, user_ids: &[String]) -> Result<Vec<Result<Option<Photo>>>> {
573 let photos = Graph::user_photos(self, user_ids).await?;
574 Ok(photos
575 .into_iter()
576 .map(|photo| photo.map_err(Into::into))
577 .collect())
578 }
579
580 async fn presences(&self, user_ids: &[String]) -> Result<Vec<Presence>> {
581 Ok(Graph::presences(self, user_ids).await?)
582 }
583
584 async fn subscribe_presence(
585 &self,
586 endpoint_id: &str,
587 trouter_uri: &str,
588 user_ids: &[String],
589 purge: bool,
590 ) -> Result<()> {
591 Ok(Graph::subscribe_presence(self, endpoint_id, trouter_uri, user_ids, purge).await?)
592 }
593
594 async fn consumption_horizons(&self, conversation_id: &str) -> Result<Vec<MemberHorizon>> {
595 Ok(Receipts::new(self.session())
596 .consumption_horizons(conversation_id)
597 .await?)
598 }
599
600 async fn chat_apps(&self, chat_id: &str) -> Result<Vec<ChatApp>> {
601 Ok(CardActions::new(self.session()).chat_apps(chat_id).await?)
602 }
603
604 async fn invoke_card(&self, invoke: InvokeRequest) -> Result<InvokeResponse> {
605 Ok(CardActions::new(self.session()).invoke(invoke).await?)
606 }
607
608 async fn message_links(
609 &self,
610 conversation: &ConversationRef,
611 page_size: usize,
612 ) -> Result<Vec<MessageLinks>> {
613 Ok(Messages::new(self.session())
614 .list_message_links(conversation, page_size)
615 .await?)
616 }
617
618 async fn set_message_links(&self, target: &MessageTarget, links_json: &str) -> Result<()> {
619 Ok(Messages::new(self.session())
620 .set_links(&conversation_ref(target), target.message_id(), links_json)
621 .await?)
622 }
623
624 async fn link_info(&self, url: &str) -> Result<LinkInfo> {
625 Ok(Messages::new(self.session()).link_info(url).await?)
626 }
627
628 async fn search_gifs(&self, query: &str) -> Result<Vec<Gif>> {
629 Ok(Gifs::new(self.session()).search(query).await?)
630 }
631}
632
633fn chatsvc_conversation(target: &MessageTarget) -> Option<ConversationRef> {
634 match target {
635 MessageTarget::Chat { .. } => CHATSVC_CHAT_WRITES.then(|| conversation_ref(target)),
636 MessageTarget::Channel { .. } => Some(conversation_ref(target)),
637 }
638}
639
640fn conversation_ref(target: &MessageTarget) -> ConversationRef {
641 match target {
642 MessageTarget::Chat { chat_id, .. } => ConversationRef::chat(chat_id),
643 MessageTarget::Channel {
644 channel_id,
645 root_id: None,
646 ..
647 } => ConversationRef::channel_root(channel_id),
648 MessageTarget::Channel {
649 channel_id,
650 root_id: Some(root_id),
651 ..
652 } => ConversationRef::channel_reply(channel_id, root_id),
653 }
654}
655
656impl From<graph::Page<Message>> for RemotePage {
657 fn from(page: graph::Page<Message>) -> Self {
658 RemotePage {
659 items: page.items,
660 next_link: page.next_link,
661 }
662 }
663}
664
665impl From<graph::Page<Message>> for DeltaPage {
666 fn from(page: graph::Page<Message>) -> Self {
667 DeltaPage {
668 items: page.items,
669 next_link: page.next_link,
670 delta_link: page.delta_link,
671 }
672 }
673}
674
675impl From<graph::Page<Chat>> for ChatsPage {
676 fn from(page: graph::Page<Chat>) -> Self {
677 ChatsPage {
678 items: page.items,
679 next_link: page.next_link,
680 }
681 }
682}
683
684#[cfg(test)]
685mod tests {
686 use super::*;
687
688 #[test]
689 fn channel_targets_route_to_chatsvc() {
690 let root = MessageTarget::channel("t", "19:c@thread.tacv2", "m1", None);
691 let reply = MessageTarget::channel("t", "19:c@thread.tacv2", "r1", Some("m1"));
692 assert_eq!(
693 chatsvc_conversation(&root),
694 Some(ConversationRef::channel_root("19:c@thread.tacv2"))
695 );
696 assert_eq!(
697 chatsvc_conversation(&reply),
698 Some(ConversationRef::channel_reply("19:c@thread.tacv2", "m1"))
699 );
700 }
701
702 #[test]
703 fn reactions_reach_chats_regardless_of_the_feature_switch() {
704 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
705 assert_eq!(
706 conversation_ref(&chat),
707 ConversationRef::chat("19:a@thread.v2")
708 );
709 }
710
711 #[test]
712 fn chats_follow_the_feature_switch() {
713 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
714 assert_eq!(chatsvc_conversation(&chat).is_some(), CHATSVC_CHAT_WRITES);
715 }
716}