BlueGit

ict rusty-teams

Files

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

remote.rs

remote.rs 43.9 KiB Download Raw
1use chatsvc::sound_settings::{SoundSettings, SoundSettingsClient};
2use chatsvc::substrate_search::{
3 QueryRequest, QueryResults, SearchIdentity, SearchSession, SubstrateSearch, Suggestions,
4};
5use chatsvc::{
6 ActivityFeed, AppConsumptionHorizon, ChatNotificationMode, ChatNotificationWrite,
7 ChatSettingChange, ChatSettingsClient, ChatSettingsDocument, DesktopNotifications,
8 MentionActivity, UserSettings, parse_app_consumption_horizon,
9};
10use chatsvc::{
11 BotProfile, BotProfiles, CallLogEntry, CardActions, ChatApp, ConversationRef,
12 ConversationState, Conversations, ForcedAvailability, ForwardResult, Gif, Gifs, HistoryShare,
13 InvokeRequest, InvokeResponse, Language, LanguageSettings, LanguageSettingsClient, LinkInfo,
14 MemberHorizon, MessageEmotions, MessageLanguage, MessageLinks, MessageWindow, Messages,
15 PinnedMessage, Pins, PresenceLookup, PresenceService, PresenceStatus, Receipts,
16 RecordingPolicy, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, ThreadMembers,
17 TranslateRequest, Translation, TranslationTrigger, Translator, WindowDirection,
18 WorkLocationKind,
19};
20use chrono::{DateTime, Utc};
21use graph::{
22 Channel, Chat, DriveEntry, DriveFolder, Graph, Member, Message, MessageExtras, MessageTarget,
23 OutgoingMention, Photo, Presence, SharedFile, Team, UploadDestination, UploadedFile, User,
24};
25
26use crate::error::{Error, Result};
27use crate::profile::PersonProfile;
28
29pub const CHATSVC_CHAT_WRITES: bool = false;
30
31#[derive(Debug, Clone)]
32pub struct RemotePage {
33 pub items: Vec<Message>,
34 pub next_link: Option<String>,
35}
36
37#[derive(Debug, Clone)]
38pub struct DeltaPage {
39 pub items: Vec<Message>,
40 pub next_link: Option<String>,
41 pub delta_link: Option<String>,
42}
43
44#[derive(Debug, Clone)]
45pub struct ChatsPage {
46 pub items: Vec<Chat>,
47 pub next_link: Option<String>,
48}
49
50#[allow(async_fn_in_trait)]
51pub trait Remote {
52 async fn me(&self) -> Result<User>;
53 async fn chats_page(&self, top: usize) -> Result<ChatsPage>;
54 async fn chats_at(&self, next_link: &str) -> Result<ChatsPage>;
55 async fn chat(&self, chat_id: &str) -> Result<Chat>;
56 async fn chat_members(&self, chat_id: &str) -> Result<Vec<Member>>;
57 async fn joined_teams(&self) -> Result<Vec<Team>>;
58 async fn channels_for_teams(&self, team_ids: &[String]) -> Result<Vec<Result<Vec<Channel>>>>;
59 async fn chat_messages(
60 &self,
61 chat_id: &str,
62 before: Option<DateTime<Utc>>,
63 top: usize,
64 ) -> Result<RemotePage>;
65 async fn chat_message(&self, chat_id: &str, message_id: &str) -> Result<Message>;
66 async fn channel_messages(
67 &self,
68 team_id: &str,
69 channel_id: &str,
70 top: usize,
71 ) -> Result<RemotePage>;
72 async fn channel_messages_at(&self, next_link: &str) -> Result<RemotePage>;
73 async fn channel_message(
74 &self,
75 team_id: &str,
76 channel_id: &str,
77 message_id: &str,
78 ) -> Result<Message>;
79 async fn channel_reply(
80 &self,
81 team_id: &str,
82 channel_id: &str,
83 message_id: &str,
84 reply_id: &str,
85 ) -> Result<Message>;
86 async fn channel_delta(
87 &self,
88 team_id: &str,
89 channel_id: &str,
90 modified_after: Option<DateTime<Utc>>,
91 ) -> Result<DeltaPage>;
92 async fn channel_delta_at(&self, link: &str) -> Result<DeltaPage>;
93 async fn channel_replies(
94 &self,
95 team_id: &str,
96 channel_id: &str,
97 root_ids: &[String],
98 ) -> Result<Vec<Result<Vec<Message>>>>;
99 async fn send_chat_message(
100 &self,
101 chat_id: &str,
102 html: &str,
103 mentions: &[OutgoingMention],
104 extras: &MessageExtras,
105 ) -> Result<Message>;
106 async fn send_channel_message(
107 &self,
108 team_id: &str,
109 channel_id: &str,
110 html: &str,
111 subject: Option<&str>,
112 mentions: &[OutgoingMention],
113 extras: &MessageExtras,
114 ) -> Result<Message>;
115 async fn reply_to_channel_message(
116 &self,
117 team_id: &str,
118 channel_id: &str,
119 message_id: &str,
120 html: &str,
121 mentions: &[OutgoingMention],
122 extras: &MessageExtras,
123 ) -> Result<Message>;
124 async fn mark_chat_read(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
125 async fn mark_chat_unread(
126 &self,
127 chat_id: &str,
128 user_id: &str,
129 tenant_id: &str,
130 last_read_at: DateTime<Utc>,
131 ) -> Result<()>;
132 async fn hide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
133 async fn unhide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()>;
134 async fn remove_chat_member(&self, chat_id: &str, user_id: &str) -> Result<()>;
135 async fn add_chat_members(
136 &self,
137 chat_id: &str,
138 user_ids: &[String],
139 share: HistoryShare,
140 ) -> Result<()>;
141 async fn chat_states(&self) -> Result<Vec<ConversationState>>;
142 async fn set_chat_muted(&self, chat_id: &str, muted: bool) -> Result<()>;
143 async fn set_read_horizon(&self, conversation_id: &str, horizon: &str) -> Result<()>;
144 async fn set_channel_notifications(
145 &self,
146 channel_id: &str,
147 notifications: store::ChannelNotifications,
148 ) -> Result<()>;
149 async fn send_typing(&self, conversation: &ConversationRef, active: bool) -> Result<()>;
150 async fn set_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()>;
151 async fn unset_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()>;
152 async fn edit_message(
153 &self,
154 target: &MessageTarget,
155 html: &str,
156 mentions: &[OutgoingMention],
157 extras: &MessageExtras,
158 ) -> Result<()>;
159 async fn soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()>;
160 async fn undo_soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()>;
161 async fn create_one_on_one(&self, my_user_id: &str, user_id: &str) -> Result<Chat>;
162 async fn create_group(
163 &self,
164 my_user_id: &str,
165 user_ids: &[String],
166 topic: Option<&str>,
167 ) -> Result<Chat>;
168 async fn search_people(&self, query: &str) -> Result<Vec<User>>;
169
170 async fn reply_with_quote(
171 &self,
172 _chat_id: &str,
173 _quoted_message_id: &str,
174 _html: &str,
175 _mentions: &[OutgoingMention],
176 _extras: &MessageExtras,
177 ) -> Result<Message> {
178 Err(Error::Unsupported("a quoted reply"))
179 }
180
181 async fn channel_files_folder(&self, _team_id: &str, _channel_id: &str) -> Result<DriveFolder> {
182 Err(Error::Unsupported("a channel files folder"))
183 }
184
185 async fn channel_files_root(&self, _team_id: &str, _channel_id: &str) -> Result<DriveEntry> {
186 Err(Error::Unsupported("a channel library"))
187 }
188
189 async fn channel_tab_web_url(
190 &self,
191 _team_id: &str,
192 _channel_id: &str,
193 _tab_id: &str,
194 ) -> Result<Option<String>> {
195 Err(Error::Unsupported("a channel tab link"))
196 }
197
198 async fn list_children(&self, _folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
199 Err(Error::Unsupported("a folder listing"))
200 }
201
202 async fn create_folder(&self, _parent: &DriveFolder, _name: &str) -> Result<DriveEntry> {
203 Err(Error::Unsupported("creating a folder"))
204 }
205
206 async fn upload_file(
207 &self,
208 _destination: &UploadDestination,
209 _file_name: &str,
210 _bytes: &[u8],
211 _progress: &(dyn Fn(u8) + Send + Sync),
212 ) -> Result<UploadedFile> {
213 Err(Error::Unsupported("a file upload"))
214 }
215
216 async fn share_file(&self, _file: &UploadedFile, _user_ids: &[String]) -> Result<()> {
217 Err(Error::Unsupported("sharing a file"))
218 }
219
220 async fn delete_file(&self, _file: &UploadedFile) -> Result<()> {
221 Err(Error::Unsupported("deleting a file"))
222 }
223
224 async fn resolve_share(&self, _open_url: &str) -> Result<SharedFile> {
225 Err(Error::Unsupported("resolving a shared file"))
226 }
227
228 async fn resolve_drive_item(&self, _drive_id: &str, _item_id: &str) -> Result<SharedFile> {
229 Err(Error::Unsupported("resolving a drive item"))
230 }
231
232 async fn download_range(
233 &self,
234 _download_url: &str,
235 _start: u64,
236 _end: Option<u64>,
237 ) -> Result<Vec<u8>> {
238 Err(Error::Unsupported("a file download"))
239 }
240
241 async fn hosted_content(&self, _url: &str) -> Result<Photo> {
242 Err(Error::Unsupported("hosted content"))
243 }
244
245 async fn external_image(&self, _url: &str) -> Result<Photo> {
246 Err(Error::Unsupported("external images"))
247 }
248
249 async fn user_photos(&self, _user_ids: &[String]) -> Result<Vec<Result<Option<Photo>>>> {
250 Err(Error::Unsupported("profile photos"))
251 }
252
253 async fn presences(&self, _user_ids: &[String]) -> Result<Vec<Presence>> {
254 Err(Error::Unsupported("presence"))
255 }
256
257 async fn person_profile(&self, _user_id: &str) -> Result<PersonProfile> {
258 Err(Error::Unsupported("profile cards"))
259 }
260
261 async fn bot_profiles(&self, _bot_ids: &[String]) -> Result<Vec<BotProfile>> {
262 Err(Error::Unsupported("bot profiles"))
263 }
264
265 async fn subscribe_presence(
266 &self,
267 _endpoint_id: &str,
268 _trouter_uri: &str,
269 _user_ids: &[String],
270 _purge: bool,
271 ) -> Result<()> {
272 Err(Error::Unsupported("presence subscriptions"))
273 }
274
275 async fn own_status(&self, _user_id: &str) -> Result<PresenceStatus> {
276 Err(Error::Unsupported("own status"))
277 }
278
279 async fn set_availability(&self, _forced: Option<&ForcedAvailability>) -> Result<()> {
280 Err(Error::Unsupported("setting availability"))
281 }
282
283 async fn set_status_note(&self, _note: Option<&StatusNote>) -> Result<()> {
284 Err(Error::Unsupported("setting the status message"))
285 }
286
287 async fn set_work_location(
288 &self,
289 _location: Option<(WorkLocationKind, DateTime<Utc>)>,
290 ) -> Result<()> {
291 Err(Error::Unsupported("setting the work location"))
292 }
293
294 async fn consumption_horizons(&self, _conversation_id: &str) -> Result<Vec<MemberHorizon>> {
295 Err(Error::Unsupported("read receipts"))
296 }
297
298 async fn forward_messages(
299 &self,
300 _source_conversation_id: &str,
301 _target_conversation_id: &str,
302 _message_ids: &[String],
303 _comment_html: &str,
304 ) -> Result<ForwardResult> {
305 Err(Error::Unsupported("forwarding messages"))
306 }
307
308 async fn set_saved(
309 &self,
310 _conversation_id: &str,
311 _root_id: &str,
312 _message_id: &str,
313 _saved: bool,
314 ) -> Result<()> {
315 Err(Error::Unsupported("saving messages"))
316 }
317
318 async fn list_saved(&self) -> Result<Vec<SavedMessage>> {
319 Err(Error::Unsupported("saved messages"))
320 }
321
322 async fn list_call_logs(&self) -> Result<Vec<CallLogEntry>> {
323 Err(Error::Unsupported("call history"))
324 }
325
326 async fn chat_message_window(
327 &self,
328 _chat_id: &str,
329 _anchor_id: &str,
330 _direction: WindowDirection,
331 _page_size: usize,
332 ) -> Result<MessageWindow> {
333 Err(Error::Unsupported("message windows"))
334 }
335
336 async fn chat_messages_by_id(
337 &self,
338 _chat_id: &str,
339 _message_ids: &[String],
340 ) -> Result<Vec<Result<Message>>> {
341 Err(Error::Unsupported("batched message reads"))
342 }
343
344 async fn chat_pins(&self, _chat_id: &str) -> Result<Vec<PinnedMessage>> {
345 Err(Error::Unsupported("pinned messages"))
346 }
347
348 async fn pin_message(&self, _chat_id: &str, _message_id: &str) -> Result<()> {
349 Err(Error::Unsupported("pinning messages"))
350 }
351
352 async fn unpin_message(
353 &self,
354 _chat_id: &str,
355 _message_id: &str,
356 _parent_id: Option<&str>,
357 ) -> Result<()> {
358 Err(Error::Unsupported("pinning messages"))
359 }
360
361 async fn channel_pinned_posts(
362 &self,
363 _team_thread_id: &str,
364 _channel_id: &str,
365 ) -> Result<Vec<PinnedMessage>> {
366 Err(Error::Unsupported("pinned channel posts"))
367 }
368
369 async fn set_post_pinned(
370 &self,
371 _team_thread_id: &str,
372 _channel_id: &str,
373 _post_id: &str,
374 _pinned: bool,
375 ) -> Result<()> {
376 Err(Error::Unsupported("pinning channel posts"))
377 }
378
379 async fn mention_activities(&self) -> Result<Vec<MentionActivity>> {
380 Err(Error::Unsupported("the activity feed"))
381 }
382
383 async fn app_consumption_horizon(&self) -> Result<AppConsumptionHorizon> {
384 Ok(AppConsumptionHorizon::default())
385 }
386
387 async fn mark_all_channels_read(&self, _now_ms: i64) -> Result<AppConsumptionHorizon> {
388 Err(Error::Unsupported("marking all channels as read"))
389 }
390
391 async fn chat_apps(&self, _chat_id: &str) -> Result<Vec<ChatApp>> {
392 Err(Error::Unsupported("chat apps"))
393 }
394
395 async fn invoke_card(&self, _invoke: InvokeRequest) -> Result<InvokeResponse> {
396 Err(Error::Unsupported("card actions"))
397 }
398
399 async fn message_links(
400 &self,
401 _conversation: &ConversationRef,
402 _page_size: usize,
403 ) -> Result<Vec<MessageLinks>> {
404 Err(Error::Unsupported("link previews"))
405 }
406
407 async fn message_emotions(
408 &self,
409 _conversation: &ConversationRef,
410 _newest_message_id: &str,
411 _page_size: usize,
412 ) -> Result<Vec<MessageEmotions>> {
413 Err(Error::Unsupported("chat service reactions"))
414 }
415
416 async fn set_message_links(&self, _target: &MessageTarget, _links_json: &str) -> Result<()> {
417 Err(Error::Unsupported("link previews"))
418 }
419
420 async fn link_info(&self, _url: &str) -> Result<LinkInfo> {
421 Err(Error::Unsupported("link previews"))
422 }
423
424 async fn message_languages(
425 &self,
426 _conversation: &ConversationRef,
427 _page_size: usize,
428 ) -> Result<Vec<MessageLanguage>> {
429 Err(Error::Unsupported("message languages"))
430 }
431
432 async fn translate_chat_messages(
433 &self,
434 _chat_id: &str,
435 _to_language: &str,
436 _messages: &[TranslateRequest],
437 _trigger: &TranslationTrigger,
438 ) -> Result<Vec<Translation>> {
439 Err(Error::Unsupported("translation"))
440 }
441
442 async fn translate_channel_messages(
443 &self,
444 _team_id: &str,
445 _channel_id: &str,
446 _root_id: &str,
447 _to_language: &str,
448 _messages: &[TranslateRequest],
449 _trigger: &TranslationTrigger,
450 ) -> Result<Vec<Translation>> {
451 Err(Error::Unsupported("translation"))
452 }
453
454 async fn translation_languages(&self, _locale: &str) -> Result<Vec<Language>> {
455 Err(Error::Unsupported("translation"))
456 }
457
458 async fn language_settings(&self) -> Result<LanguageSettings> {
459 Err(Error::Unsupported("translation settings"))
460 }
461
462 async fn patch_language_settings(&self, _patch: serde_json::Value) -> Result<()> {
463 Err(Error::Unsupported("translation settings"))
464 }
465
466 async fn recording_policy(&self) -> Result<RecordingPolicy> {
467 Err(Error::Unsupported("recording policy"))
468 }
469
470 async fn sound_settings(&self) -> Result<SoundSettings> {
471 Err(Error::Unsupported("sound settings"))
472 }
473
474 async fn chat_settings(&self) -> Result<ChatSettingsDocument> {
475 Err(Error::Unsupported("chat settings"))
476 }
477
478 async fn save_chat_setting(&self, _change: ChatSettingChange) -> Result<ChatSettingsDocument> {
479 Err(Error::Unsupported("chat settings"))
480 }
481
482 async fn set_chat_notifications(
483 &self,
484 _chat_id: &str,
485 _current_settings: Option<&str>,
486 _mode: ChatNotificationMode,
487 _desktop: DesktopNotifications,
488 ) -> Result<ChatNotificationWrite> {
489 Err(Error::Unsupported("chat notifications"))
490 }
491
492 async fn save_sound_settings(
493 &self,
494 _user_mri: &str,
495 _previous: &SoundSettings,
496 _updated: &SoundSettings,
497 ) -> Result<()> {
498 Err(Error::Unsupported("sound settings"))
499 }
500
501 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
502 Err(Error::Unsupported("GIF search"))
503 }
504
505 async fn server_search_init(
506 &self,
507 _identity: &SearchIdentity,
508 _search_session: &SearchSession,
509 ) -> Result<()> {
510 Err(Error::Unsupported("server search"))
511 }
512
513 async fn server_suggestions(
514 &self,
515 _identity: &SearchIdentity,
516 _search_session: &SearchSession,
517 _text: &str,
518 ) -> Result<Suggestions> {
519 Err(Error::Unsupported("server search"))
520 }
521
522 async fn server_query(
523 &self,
524 _identity: &SearchIdentity,
525 _search_session: &SearchSession,
526 _request: &QueryRequest,
527 ) -> Result<QueryResults> {
528 Err(Error::Unsupported("server search"))
529 }
530
531 async fn create_scheduled(
532 &self,
533 _inner_thread_id: &str,
534 _html: &str,
535 _send_at: DateTime<Utc>,
536 _display_name: &str,
537 ) -> Result<ScheduledDraft> {
538 Err(Error::Unsupported("schedule send"))
539 }
540
541 async fn scheduled_drafts(&self) -> Result<Vec<ScheduledDraft>> {
542 Err(Error::Unsupported("schedule send"))
543 }
544
545 async fn update_scheduled(
546 &self,
547 _draft: &ScheduledDraft,
548 _html: &str,
549 _display_name: &str,
550 ) -> Result<ScheduledDraft> {
551 Err(Error::Unsupported("schedule send"))
552 }
553
554 async fn cancel_scheduled(&self, _draft_id: &str) -> Result<()> {
555 Err(Error::Unsupported("schedule send"))
556 }
557}
558
559impl Remote for Graph {
560 async fn me(&self) -> Result<User> {
561 Ok(Graph::me(self).await?)
562 }
563
564 async fn chats_page(&self, top: usize) -> Result<ChatsPage> {
565 Ok(Graph::chats_page(self, top).await?.into())
566 }
567
568 async fn chats_at(&self, next_link: &str) -> Result<ChatsPage> {
569 Ok(Graph::chats_at(self, next_link).await?.into())
570 }
571
572 async fn chat(&self, chat_id: &str) -> Result<Chat> {
573 Ok(Graph::chat(self, chat_id).await?)
574 }
575
576 async fn chat_members(&self, chat_id: &str) -> Result<Vec<Member>> {
577 Ok(Graph::chat_members(self, chat_id).await?)
578 }
579
580 async fn joined_teams(&self) -> Result<Vec<Team>> {
581 Ok(Graph::joined_teams(self).await?)
582 }
583
584 async fn channels_for_teams(&self, team_ids: &[String]) -> Result<Vec<Result<Vec<Channel>>>> {
585 let listings = Graph::channels_for_teams(self, team_ids).await?;
586 Ok(listings
587 .into_iter()
588 .map(|listing| listing.map_err(Into::into))
589 .collect())
590 }
591
592 async fn chat_messages(
593 &self,
594 chat_id: &str,
595 before: Option<DateTime<Utc>>,
596 top: usize,
597 ) -> Result<RemotePage> {
598 Ok(Graph::chat_messages(self, chat_id, before, top)
599 .await?
600 .into())
601 }
602
603 async fn chat_message(&self, chat_id: &str, message_id: &str) -> Result<Message> {
604 Ok(Graph::chat_message(self, chat_id, message_id).await?)
605 }
606
607 async fn channel_messages(
608 &self,
609 team_id: &str,
610 channel_id: &str,
611 top: usize,
612 ) -> Result<RemotePage> {
613 Ok(Graph::channel_messages(self, team_id, channel_id, top)
614 .await?
615 .into())
616 }
617
618 async fn channel_messages_at(&self, next_link: &str) -> Result<RemotePage> {
619 Ok(Graph::channel_messages_at(self, next_link).await?.into())
620 }
621
622 async fn channel_message(
623 &self,
624 team_id: &str,
625 channel_id: &str,
626 message_id: &str,
627 ) -> Result<Message> {
628 Ok(Graph::channel_message(self, team_id, channel_id, message_id).await?)
629 }
630
631 async fn channel_reply(
632 &self,
633 team_id: &str,
634 channel_id: &str,
635 message_id: &str,
636 reply_id: &str,
637 ) -> Result<Message> {
638 Ok(Graph::channel_reply(self, team_id, channel_id, message_id, reply_id).await?)
639 }
640
641 async fn channel_delta(
642 &self,
643 team_id: &str,
644 channel_id: &str,
645 modified_after: Option<DateTime<Utc>>,
646 ) -> Result<DeltaPage> {
647 Ok(
648 Graph::channel_delta(self, team_id, channel_id, modified_after)
649 .await?
650 .into(),
651 )
652 }
653
654 async fn channel_delta_at(&self, link: &str) -> Result<DeltaPage> {
655 Ok(Graph::channel_delta_at(self, link).await?.into())
656 }
657
658 async fn channel_replies(
659 &self,
660 team_id: &str,
661 channel_id: &str,
662 root_ids: &[String],
663 ) -> Result<Vec<Result<Vec<Message>>>> {
664 let listings = Graph::channel_replies(self, team_id, channel_id, root_ids).await?;
665 Ok(listings
666 .into_iter()
667 .map(|listing| listing.map_err(Into::into))
668 .collect())
669 }
670
671 async fn send_chat_message(
672 &self,
673 chat_id: &str,
674 html: &str,
675 mentions: &[OutgoingMention],
676 extras: &MessageExtras,
677 ) -> Result<Message> {
678 Ok(Graph::send_chat_message(self, chat_id, html, mentions, extras).await?)
679 }
680
681 async fn send_channel_message(
682 &self,
683 team_id: &str,
684 channel_id: &str,
685 html: &str,
686 subject: Option<&str>,
687 mentions: &[OutgoingMention],
688 extras: &MessageExtras,
689 ) -> Result<Message> {
690 Ok(
691 Graph::send_channel_message(self, team_id, channel_id, html, subject, mentions, extras)
692 .await?,
693 )
694 }
695
696 async fn reply_to_channel_message(
697 &self,
698 team_id: &str,
699 channel_id: &str,
700 message_id: &str,
701 html: &str,
702 mentions: &[OutgoingMention],
703 extras: &MessageExtras,
704 ) -> Result<Message> {
705 Ok(Graph::reply_to_channel_message(
706 self, team_id, channel_id, message_id, html, mentions, extras,
707 )
708 .await?)
709 }
710
711 async fn mark_chat_read(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
712 Ok(Graph::mark_chat_read(self, chat_id, user_id, tenant_id).await?)
713 }
714
715 async fn mark_chat_unread(
716 &self,
717 chat_id: &str,
718 user_id: &str,
719 tenant_id: &str,
720 last_read_at: DateTime<Utc>,
721 ) -> Result<()> {
722 Ok(Graph::mark_chat_unread(self, chat_id, user_id, tenant_id, last_read_at).await?)
723 }
724
725 async fn hide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
726 Ok(Graph::hide_chat(self, chat_id, user_id, tenant_id).await?)
727 }
728
729 async fn unhide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
730 Ok(Graph::unhide_chat(self, chat_id, user_id, tenant_id).await?)
731 }
732
733 async fn remove_chat_member(&self, chat_id: &str, user_id: &str) -> Result<()> {
734 Ok(ThreadMembers::new(self.session())
735 .remove(chat_id, user_id)
736 .await?)
737 }
738
739 async fn add_chat_members(
740 &self,
741 chat_id: &str,
742 user_ids: &[String],
743 share: HistoryShare,
744 ) -> Result<()> {
745 Ok(ThreadMembers::new(self.session())
746 .add(chat_id, user_ids, share, Utc::now().timestamp_millis())
747 .await?)
748 }
749
750 async fn chat_states(&self) -> Result<Vec<ConversationState>> {
751 Ok(Conversations::new(self.session())
752 .conversation_states()
753 .await?)
754 }
755
756 async fn set_chat_muted(&self, chat_id: &str, muted: bool) -> Result<()> {
757 Ok(Conversations::new(self.session())
758 .set_alerts(chat_id, !muted)
759 .await?)
760 }
761
762 async fn set_read_horizon(&self, conversation_id: &str, horizon: &str) -> Result<()> {
763 Ok(Conversations::new(self.session())
764 .set_read_horizon(conversation_id, horizon)
765 .await?)
766 }
767
768 async fn set_channel_notifications(
769 &self,
770 channel_id: &str,
771 notifications: store::ChannelNotifications,
772 ) -> Result<()> {
773 Ok(Conversations::new(self.session())
774 .set_channel_notifications(
775 channel_id,
776 crate::folders::chatsvc_notifications(notifications),
777 )
778 .await?)
779 }
780
781 async fn send_typing(&self, conversation: &ConversationRef, active: bool) -> Result<()> {
782 Ok(Messages::new(self.session())
783 .send_typing(conversation, active)
784 .await?)
785 }
786
787 async fn set_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
788 if let Some(key) = chatsvc::reaction_key(reaction_type) {
789 return Ok(Messages::new(self.session())
790 .set_emotion(&conversation_ref(target), target.message_id(), &key)
791 .await?);
792 }
793 Ok(Graph::set_reaction(self, target, reaction_type).await?)
794 }
795
796 async fn unset_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
797 let keys = chatsvc::reaction_keys(reaction_type);
798 if !keys.is_empty() {
799 let keys: Vec<&str> = keys.iter().map(String::as_str).collect();
800 return Ok(Messages::new(self.session())
801 .unset_emotions(&conversation_ref(target), target.message_id(), &keys)
802 .await?);
803 }
804 Ok(Graph::unset_reaction(self, target, reaction_type).await?)
805 }
806
807 async fn edit_message(
808 &self,
809 target: &MessageTarget,
810 html: &str,
811 mentions: &[OutgoingMention],
812 extras: &MessageExtras,
813 ) -> Result<()> {
814 match chatsvc_conversation(target) {
815 Some(conversation) if mentions.is_empty() => {
816 let html = format!("{}{html}{}", extras.kept_html(), extras.files_html());
817 Ok(Messages::new(self.session())
818 .edit_message(&conversation, target.message_id(), &html)
819 .await?)
820 }
821 Some(_) => Err(Error::Unsupported(
822 "editing a channel message with mentions",
823 )),
824 None => Ok(Graph::edit_message(self, target, html, mentions, extras).await?),
825 }
826 }
827
828 async fn soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()> {
829 match chatsvc_conversation(target) {
830 Some(conversation) => Ok(Messages::new(self.session())
831 .soft_delete_message(&conversation, target.message_id())
832 .await?),
833 None => Ok(Graph::soft_delete_message(self, user_id, target).await?),
834 }
835 }
836
837 async fn undo_soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()> {
838 match chatsvc_conversation(target) {
839 Some(conversation) => Ok(Messages::new(self.session())
840 .undelete_message(&conversation, target.message_id())
841 .await?),
842 None => Ok(Graph::undo_soft_delete_message(self, user_id, target).await?),
843 }
844 }
845
846 async fn create_one_on_one(&self, my_user_id: &str, user_id: &str) -> Result<Chat> {
847 Ok(Graph::create_one_on_one(self, my_user_id, user_id).await?)
848 }
849
850 async fn create_group(
851 &self,
852 my_user_id: &str,
853 user_ids: &[String],
854 topic: Option<&str>,
855 ) -> Result<Chat> {
856 Ok(Graph::create_group(self, my_user_id, user_ids, topic).await?)
857 }
858
859 async fn search_people(&self, query: &str) -> Result<Vec<User>> {
860 Ok(Graph::search_people(self, query).await?)
861 }
862
863 async fn reply_with_quote(
864 &self,
865 chat_id: &str,
866 quoted_message_id: &str,
867 html: &str,
868 mentions: &[OutgoingMention],
869 extras: &MessageExtras,
870 ) -> Result<Message> {
871 Ok(
872 Graph::reply_with_quote(self, chat_id, quoted_message_id, html, mentions, extras)
873 .await?,
874 )
875 }
876
877 async fn channel_files_folder(&self, team_id: &str, channel_id: &str) -> Result<DriveFolder> {
878 Ok(Graph::channel_files_folder(self, team_id, channel_id).await?)
879 }
880
881 async fn channel_files_root(&self, team_id: &str, channel_id: &str) -> Result<DriveEntry> {
882 Ok(Graph::channel_files_root(self, team_id, channel_id).await?)
883 }
884
885 async fn channel_tab_web_url(
886 &self,
887 team_id: &str,
888 channel_id: &str,
889 tab_id: &str,
890 ) -> Result<Option<String>> {
891 Ok(Graph::channel_tab_web_url(self, team_id, channel_id, tab_id).await?)
892 }
893
894 async fn list_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
895 Ok(Graph::list_children(self, folder).await?)
896 }
897
898 async fn create_folder(&self, parent: &DriveFolder, name: &str) -> Result<DriveEntry> {
899 Ok(Graph::create_folder(self, parent, name).await?)
900 }
901
902 async fn upload_file(
903 &self,
904 destination: &UploadDestination,
905 file_name: &str,
906 bytes: &[u8],
907 progress: &(dyn Fn(u8) + Send + Sync),
908 ) -> Result<UploadedFile> {
909 Ok(Graph::upload_file(self, destination, file_name, bytes, progress).await?)
910 }
911
912 async fn share_file(&self, file: &UploadedFile, user_ids: &[String]) -> Result<()> {
913 Ok(Graph::share_item(self, file, user_ids).await?)
914 }
915
916 async fn delete_file(&self, file: &UploadedFile) -> Result<()> {
917 Ok(Graph::delete_drive_item(self, &file.drive_id, &file.item_id).await?)
918 }
919
920 async fn resolve_share(&self, open_url: &str) -> Result<SharedFile> {
921 Ok(Graph::resolve_share(self, open_url).await?)
922 }
923
924 async fn resolve_drive_item(&self, drive_id: &str, item_id: &str) -> Result<SharedFile> {
925 Ok(Graph::resolve_drive_item(self, drive_id, item_id).await?)
926 }
927
928 async fn download_range(
929 &self,
930 download_url: &str,
931 start: u64,
932 end: Option<u64>,
933 ) -> Result<Vec<u8>> {
934 Ok(Graph::download_range(self, download_url, start, end).await?)
935 }
936
937 async fn hosted_content(&self, url: &str) -> Result<Photo> {
938 if chatsvc::is_link_image_url(url) {
939 let image = Messages::new(self.session()).link_image(url).await?;
940 return Ok(Photo {
941 bytes: image.bytes,
942 content_type: image.content_type,
943 });
944 }
945 Ok(Graph::download_hosted_content(self, url).await?)
946 }
947
948 async fn external_image(&self, url: &str) -> Result<Photo> {
949 Ok(Graph::download_external_image(self, url).await?)
950 }
951
952 async fn user_photos(&self, user_ids: &[String]) -> Result<Vec<Result<Option<Photo>>>> {
953 let photos = Graph::user_photos(self, user_ids).await?;
954 Ok(photos
955 .into_iter()
956 .map(|photo| photo.map_err(Into::into))
957 .collect())
958 }
959
960 async fn presences(&self, user_ids: &[String]) -> Result<Vec<Presence>> {
961 let found = PresenceLookup::new(self.session())
962 .presences(user_ids)
963 .await?;
964 Ok(found
965 .into_iter()
966 .map(|presence| Presence {
967 user_id: presence.user_id,
968 availability: presence.availability,
969 activity: presence.activity,
970 })
971 .collect())
972 }
973
974 async fn person_profile(&self, user_id: &str) -> Result<PersonProfile> {
975 crate::profile::load_profile(self, user_id).await
976 }
977
978 async fn bot_profiles(&self, bot_ids: &[String]) -> Result<Vec<BotProfile>> {
979 Ok(BotProfiles::new(self.session()).fetch(bot_ids).await?)
980 }
981
982 async fn subscribe_presence(
983 &self,
984 endpoint_id: &str,
985 trouter_uri: &str,
986 user_ids: &[String],
987 purge: bool,
988 ) -> Result<()> {
989 Ok(PresenceLookup::new(self.session())
990 .subscribe(endpoint_id, trouter_uri, user_ids, purge)
991 .await?)
992 }
993
994 async fn own_status(&self, user_id: &str) -> Result<PresenceStatus> {
995 Ok(PresenceService::new(self.session()).status(user_id).await?)
996 }
997
998 async fn set_availability(&self, forced: Option<&ForcedAvailability>) -> Result<()> {
999 Ok(PresenceService::new(self.session())
1000 .set_availability(forced)
1001 .await?)
1002 }
1003
1004 async fn set_status_note(&self, note: Option<&StatusNote>) -> Result<()> {
1005 Ok(PresenceService::new(self.session()).set_note(note).await?)
1006 }
1007
1008 async fn set_work_location(
1009 &self,
1010 location: Option<(WorkLocationKind, DateTime<Utc>)>,
1011 ) -> Result<()> {
1012 Ok(PresenceService::new(self.session())
1013 .set_work_location(location)
1014 .await?)
1015 }
1016
1017 async fn consumption_horizons(&self, conversation_id: &str) -> Result<Vec<MemberHorizon>> {
1018 Ok(Receipts::new(self.session())
1019 .consumption_horizons(conversation_id)
1020 .await?)
1021 }
1022
1023 async fn forward_messages(
1024 &self,
1025 source_conversation_id: &str,
1026 target_conversation_id: &str,
1027 message_ids: &[String],
1028 comment_html: &str,
1029 ) -> Result<ForwardResult> {
1030 Ok(Messages::new(self.session())
1031 .forward_messages(
1032 source_conversation_id,
1033 target_conversation_id,
1034 message_ids,
1035 comment_html,
1036 )
1037 .await?)
1038 }
1039
1040 async fn set_saved(
1041 &self,
1042 conversation_id: &str,
1043 root_id: &str,
1044 message_id: &str,
1045 saved: bool,
1046 ) -> Result<()> {
1047 Ok(Messages::new(self.session())
1048 .set_saved(conversation_id, root_id, message_id, saved)
1049 .await?)
1050 }
1051
1052 async fn list_saved(&self) -> Result<Vec<SavedMessage>> {
1053 Ok(Messages::new(self.session()).list_saved().await?)
1054 }
1055
1056 async fn list_call_logs(&self) -> Result<Vec<CallLogEntry>> {
1057 Ok(Messages::new(self.session()).list_call_logs().await?)
1058 }
1059
1060 async fn chat_message_window(
1061 &self,
1062 chat_id: &str,
1063 anchor_id: &str,
1064 direction: WindowDirection,
1065 page_size: usize,
1066 ) -> Result<MessageWindow> {
1067 Ok(Messages::new(self.session())
1068 .message_window(chat_id, anchor_id, direction, page_size)
1069 .await?)
1070 }
1071
1072 async fn chat_messages_by_id(
1073 &self,
1074 chat_id: &str,
1075 message_ids: &[String],
1076 ) -> Result<Vec<Result<Message>>> {
1077 let messages = Graph::chat_messages_by_id(self, chat_id, message_ids).await?;
1078 Ok(messages
1079 .into_iter()
1080 .map(|message| message.map_err(Into::into))
1081 .collect())
1082 }
1083
1084 async fn chat_pins(&self, chat_id: &str) -> Result<Vec<PinnedMessage>> {
1085 Ok(Pins::new(self.session()).chat_pins(chat_id).await?)
1086 }
1087
1088 async fn pin_message(&self, chat_id: &str, message_id: &str) -> Result<()> {
1089 Ok(Pins::new(self.session())
1090 .pin_message(chat_id, message_id)
1091 .await?)
1092 }
1093
1094 async fn unpin_message(
1095 &self,
1096 chat_id: &str,
1097 message_id: &str,
1098 parent_id: Option<&str>,
1099 ) -> Result<()> {
1100 Ok(Pins::new(self.session())
1101 .unpin_message(chat_id, message_id, parent_id)
1102 .await?)
1103 }
1104
1105 async fn channel_pinned_posts(
1106 &self,
1107 team_thread_id: &str,
1108 channel_id: &str,
1109 ) -> Result<Vec<PinnedMessage>> {
1110 Ok(Pins::with_skype_token(self.session())
1111 .channel_pinned_posts(team_thread_id, channel_id)
1112 .await?)
1113 }
1114
1115 async fn set_post_pinned(
1116 &self,
1117 team_thread_id: &str,
1118 channel_id: &str,
1119 post_id: &str,
1120 pinned: bool,
1121 ) -> Result<()> {
1122 Ok(Pins::with_skype_token(self.session())
1123 .set_post_pinned(team_thread_id, channel_id, post_id, pinned)
1124 .await?)
1125 }
1126
1127 async fn mention_activities(&self) -> Result<Vec<MentionActivity>> {
1128 Ok(ActivityFeed::new(self.session()).mentions().await?)
1129 }
1130
1131 async fn app_consumption_horizon(&self) -> Result<AppConsumptionHorizon> {
1132 let properties = UserSettings::new(self.session()).properties().await?;
1133 Ok(parse_app_consumption_horizon(&properties))
1134 }
1135
1136 async fn mark_all_channels_read(&self, now_ms: i64) -> Result<AppConsumptionHorizon> {
1137 Ok(UserSettings::new(self.session())
1138 .mark_all_channels_read(now_ms)
1139 .await?)
1140 }
1141
1142 async fn chat_apps(&self, chat_id: &str) -> Result<Vec<ChatApp>> {
1143 Ok(CardActions::new(self.session()).chat_apps(chat_id).await?)
1144 }
1145
1146 async fn invoke_card(&self, invoke: InvokeRequest) -> Result<InvokeResponse> {
1147 Ok(CardActions::new(self.session()).invoke(invoke).await?)
1148 }
1149
1150 async fn message_links(
1151 &self,
1152 conversation: &ConversationRef,
1153 page_size: usize,
1154 ) -> Result<Vec<MessageLinks>> {
1155 Ok(Messages::new(self.session())
1156 .list_message_links(conversation, page_size)
1157 .await?)
1158 }
1159
1160 async fn message_emotions(
1161 &self,
1162 conversation: &ConversationRef,
1163 newest_message_id: &str,
1164 page_size: usize,
1165 ) -> Result<Vec<MessageEmotions>> {
1166 Ok(Messages::new(self.session())
1167 .message_emotions(
1168 &conversation.conversation_id(),
1169 newest_message_id,
1170 page_size,
1171 )
1172 .await?)
1173 }
1174
1175 async fn set_message_links(&self, target: &MessageTarget, links_json: &str) -> Result<()> {
1176 Ok(Messages::new(self.session())
1177 .set_links(&conversation_ref(target), target.message_id(), links_json)
1178 .await?)
1179 }
1180
1181 async fn link_info(&self, url: &str) -> Result<LinkInfo> {
1182 Ok(Messages::new(self.session()).link_info(url).await?)
1183 }
1184
1185 async fn message_languages(
1186 &self,
1187 conversation: &ConversationRef,
1188 page_size: usize,
1189 ) -> Result<Vec<MessageLanguage>> {
1190 Ok(Messages::new(self.session())
1191 .list_language_stamps(conversation, page_size)
1192 .await?)
1193 }
1194
1195 async fn translate_chat_messages(
1196 &self,
1197 chat_id: &str,
1198 to_language: &str,
1199 messages: &[TranslateRequest],
1200 trigger: &TranslationTrigger,
1201 ) -> Result<Vec<Translation>> {
1202 Ok(Translator::new(self.session())
1203 .translate_chat(chat_id, to_language, messages, trigger)
1204 .await?)
1205 }
1206
1207 async fn translate_channel_messages(
1208 &self,
1209 team_id: &str,
1210 channel_id: &str,
1211 root_id: &str,
1212 to_language: &str,
1213 messages: &[TranslateRequest],
1214 trigger: &TranslationTrigger,
1215 ) -> Result<Vec<Translation>> {
1216 Ok(Translator::new(self.session())
1217 .translate_channel(team_id, channel_id, root_id, to_language, messages, trigger)
1218 .await?)
1219 }
1220
1221 async fn translation_languages(&self, locale: &str) -> Result<Vec<Language>> {
1222 Ok(Translator::new(self.session()).languages(locale).await?)
1223 }
1224
1225 async fn language_settings(&self) -> Result<LanguageSettings> {
1226 Ok(LanguageSettingsClient::new(self.session()).read().await?)
1227 }
1228
1229 async fn recording_policy(&self) -> Result<RecordingPolicy> {
1230 Ok(LanguageSettingsClient::new(self.session())
1231 .read_recording_policy()
1232 .await?)
1233 }
1234
1235 async fn patch_language_settings(&self, patch: serde_json::Value) -> Result<()> {
1236 Ok(LanguageSettingsClient::new(self.session())
1237 .patch(patch)
1238 .await?)
1239 }
1240
1241 async fn sound_settings(&self) -> Result<SoundSettings> {
1242 Ok(SoundSettingsClient::new(self.session()).read().await?)
1243 }
1244
1245 async fn chat_settings(&self) -> Result<ChatSettingsDocument> {
1246 Ok(ChatSettingsClient::new(self.session()).read().await?)
1247 }
1248
1249 async fn save_chat_setting(&self, change: ChatSettingChange) -> Result<ChatSettingsDocument> {
1250 Ok(ChatSettingsClient::new(self.session()).write(change).await?)
1251 }
1252
1253 async fn set_chat_notifications(
1254 &self,
1255 chat_id: &str,
1256 current_settings: Option<&str>,
1257 mode: ChatNotificationMode,
1258 desktop: DesktopNotifications,
1259 ) -> Result<ChatNotificationWrite> {
1260 Ok(Conversations::new(self.session())
1261 .set_chat_notifications(chat_id, current_settings, mode, desktop)
1262 .await?)
1263 }
1264
1265 async fn save_sound_settings(
1266 &self,
1267 user_mri: &str,
1268 previous: &SoundSettings,
1269 updated: &SoundSettings,
1270 ) -> Result<()> {
1271 Ok(SoundSettingsClient::new(self.session())
1272 .write(user_mri, previous, updated)
1273 .await?)
1274 }
1275
1276 async fn search_gifs(&self, query: &str) -> Result<Vec<Gif>> {
1277 Ok(Gifs::new(self.session()).search(query).await?)
1278 }
1279
1280 async fn server_search_init(
1281 &self,
1282 identity: &SearchIdentity,
1283 search_session: &SearchSession,
1284 ) -> Result<()> {
1285 Ok(SubstrateSearch::new(self.session(), identity.clone())
1286 .init(search_session)
1287 .await?)
1288 }
1289
1290 async fn server_suggestions(
1291 &self,
1292 identity: &SearchIdentity,
1293 search_session: &SearchSession,
1294 text: &str,
1295 ) -> Result<Suggestions> {
1296 Ok(SubstrateSearch::new(self.session(), identity.clone())
1297 .suggestions(search_session, text)
1298 .await?)
1299 }
1300
1301 async fn server_query(
1302 &self,
1303 identity: &SearchIdentity,
1304 search_session: &SearchSession,
1305 request: &QueryRequest,
1306 ) -> Result<QueryResults> {
1307 Ok(SubstrateSearch::new(self.session(), identity.clone())
1308 .query(search_session, request)
1309 .await?)
1310 }
1311
1312 async fn create_scheduled(
1313 &self,
1314 inner_thread_id: &str,
1315 html: &str,
1316 send_at: DateTime<Utc>,
1317 display_name: &str,
1318 ) -> Result<ScheduledDraft> {
1319 Ok(ScheduledDrafts::new(self.session())
1320 .create(inner_thread_id, html, send_at, display_name)
1321 .await?)
1322 }
1323
1324 async fn scheduled_drafts(&self) -> Result<Vec<ScheduledDraft>> {
1325 Ok(ScheduledDrafts::new(self.session()).list().await?)
1326 }
1327
1328 async fn update_scheduled(
1329 &self,
1330 draft: &ScheduledDraft,
1331 html: &str,
1332 display_name: &str,
1333 ) -> Result<ScheduledDraft> {
1334 Ok(ScheduledDrafts::new(self.session())
1335 .update(draft, html, display_name)
1336 .await?)
1337 }
1338
1339 async fn cancel_scheduled(&self, draft_id: &str) -> Result<()> {
1340 Ok(ScheduledDrafts::new(self.session())
1341 .cancel(draft_id)
1342 .await?)
1343 }
1344}
1345
1346fn chatsvc_conversation(target: &MessageTarget) -> Option<ConversationRef> {
1347 match target {
1348 MessageTarget::Chat { .. } => CHATSVC_CHAT_WRITES.then(|| conversation_ref(target)),
1349 MessageTarget::Channel { .. } => Some(conversation_ref(target)),
1350 }
1351}
1352
1353fn conversation_ref(target: &MessageTarget) -> ConversationRef {
1354 match target {
1355 MessageTarget::Chat { chat_id, .. } => ConversationRef::chat(chat_id),
1356 MessageTarget::Channel {
1357 channel_id,
1358 root_id: None,
1359 ..
1360 } => ConversationRef::channel_root(channel_id),
1361 MessageTarget::Channel {
1362 channel_id,
1363 root_id: Some(root_id),
1364 ..
1365 } => ConversationRef::channel_reply(channel_id, root_id),
1366 }
1367}
1368
1369impl From<graph::Page<Message>> for RemotePage {
1370 fn from(page: graph::Page<Message>) -> Self {
1371 RemotePage {
1372 items: page.items,
1373 next_link: page.next_link,
1374 }
1375 }
1376}
1377
1378impl From<graph::Page<Message>> for DeltaPage {
1379 fn from(page: graph::Page<Message>) -> Self {
1380 DeltaPage {
1381 items: page.items,
1382 next_link: page.next_link,
1383 delta_link: page.delta_link,
1384 }
1385 }
1386}
1387
1388impl From<graph::Page<Chat>> for ChatsPage {
1389 fn from(page: graph::Page<Chat>) -> Self {
1390 ChatsPage {
1391 items: page.items,
1392 next_link: page.next_link,
1393 }
1394 }
1395}
1396
1397#[cfg(test)]
1398mod tests {
1399 use super::*;
1400
1401 #[test]
1402 fn channel_targets_route_to_chatsvc() {
1403 let root = MessageTarget::channel("t", "19:c@thread.tacv2", "m1", None);
1404 let reply = MessageTarget::channel("t", "19:c@thread.tacv2", "r1", Some("m1"));
1405 assert_eq!(
1406 chatsvc_conversation(&root),
1407 Some(ConversationRef::channel_root("19:c@thread.tacv2"))
1408 );
1409 assert_eq!(
1410 chatsvc_conversation(&reply),
1411 Some(ConversationRef::channel_reply("19:c@thread.tacv2", "m1"))
1412 );
1413 }
1414
1415 #[test]
1416 fn reactions_reach_chats_regardless_of_the_feature_switch() {
1417 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
1418 assert_eq!(
1419 conversation_ref(&chat),
1420 ConversationRef::chat("19:a@thread.v2")
1421 );
1422 }
1423
1424 #[test]
1425 fn chats_follow_the_feature_switch() {
1426 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
1427 assert_eq!(chatsvc_conversation(&chat).is_some(), CHATSVC_CHAT_WRITES);
1428 }
1429}