BlueGit

ict rusty-teams

Files

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

remote.rs

remote.rs 43.4 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, MentionActivity, UserSettings,
7 parse_app_consumption_horizon,
8};
9use chatsvc::{
10 BotProfile, BotProfiles, CallLogEntry, CardActions, ChatApp, ConversationRef,
11 ConversationState, Conversations, ForcedAvailability, ForwardResult, Gif, Gifs, HistoryShare,
12 InvokeRequest, InvokeResponse, Language, LanguageSettings, LanguageSettingsClient, LinkInfo,
13 MemberHorizon, MessageEmotions, MessageLanguage, MessageLinks, MessageWindow, Messages,
14 PinnedMessage, Pins, PresenceLookup, PresenceService, PresenceStatus, Receipts,
15 RecordingPolicy, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, ThreadMembers,
16 TranslateRequest, Translation, TranslationTrigger, Translator, WindowDirection,
17 WorkLocationKind,
18};
19use chrono::{DateTime, Utc};
20use graph::{
21 Channel, Chat, DriveEntry, DriveFolder, Graph, Member, Message, MessageExtras, MessageTarget,
22 OutgoingMention, Photo, Presence, SharedFile, Team, UploadDestination, UploadedFile, User,
23};
24
25use crate::error::{Error, Result};
26use crate::profile::PersonProfile;
27
28pub const CHATSVC_CHAT_WRITES: bool = false;
29const URGENT_ACK_EMOTION: &str = "acks";
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 allow_priority_messages(&self) -> Result<bool> {
471 Err(Error::Unsupported("messaging policy"))
472 }
473
474 async fn ack_urgent_message(&self, _chat_id: &str, _message_id: &str) -> Result<()> {
475 Err(Error::Unsupported("urgent message acknowledgement"))
476 }
477
478 async fn sound_settings(&self) -> Result<SoundSettings> {
479 Err(Error::Unsupported("sound settings"))
480 }
481
482 async fn save_sound_settings(
483 &self,
484 _user_mri: &str,
485 _previous: &SoundSettings,
486 _updated: &SoundSettings,
487 ) -> Result<()> {
488 Err(Error::Unsupported("sound settings"))
489 }
490
491 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
492 Err(Error::Unsupported("GIF search"))
493 }
494
495 async fn server_search_init(
496 &self,
497 _identity: &SearchIdentity,
498 _search_session: &SearchSession,
499 ) -> Result<()> {
500 Err(Error::Unsupported("server search"))
501 }
502
503 async fn server_suggestions(
504 &self,
505 _identity: &SearchIdentity,
506 _search_session: &SearchSession,
507 _text: &str,
508 ) -> Result<Suggestions> {
509 Err(Error::Unsupported("server search"))
510 }
511
512 async fn server_query(
513 &self,
514 _identity: &SearchIdentity,
515 _search_session: &SearchSession,
516 _request: &QueryRequest,
517 ) -> Result<QueryResults> {
518 Err(Error::Unsupported("server search"))
519 }
520
521 async fn create_scheduled(
522 &self,
523 _inner_thread_id: &str,
524 _html: &str,
525 _send_at: DateTime<Utc>,
526 _display_name: &str,
527 ) -> Result<ScheduledDraft> {
528 Err(Error::Unsupported("schedule send"))
529 }
530
531 async fn scheduled_drafts(&self) -> Result<Vec<ScheduledDraft>> {
532 Err(Error::Unsupported("schedule send"))
533 }
534
535 async fn update_scheduled(
536 &self,
537 _draft: &ScheduledDraft,
538 _html: &str,
539 _display_name: &str,
540 ) -> Result<ScheduledDraft> {
541 Err(Error::Unsupported("schedule send"))
542 }
543
544 async fn cancel_scheduled(&self, _draft_id: &str) -> Result<()> {
545 Err(Error::Unsupported("schedule send"))
546 }
547}
548
549impl Remote for Graph {
550 async fn me(&self) -> Result<User> {
551 Ok(Graph::me(self).await?)
552 }
553
554 async fn chats_page(&self, top: usize) -> Result<ChatsPage> {
555 Ok(Graph::chats_page(self, top).await?.into())
556 }
557
558 async fn chats_at(&self, next_link: &str) -> Result<ChatsPage> {
559 Ok(Graph::chats_at(self, next_link).await?.into())
560 }
561
562 async fn chat(&self, chat_id: &str) -> Result<Chat> {
563 Ok(Graph::chat(self, chat_id).await?)
564 }
565
566 async fn chat_members(&self, chat_id: &str) -> Result<Vec<Member>> {
567 Ok(Graph::chat_members(self, chat_id).await?)
568 }
569
570 async fn joined_teams(&self) -> Result<Vec<Team>> {
571 Ok(Graph::joined_teams(self).await?)
572 }
573
574 async fn channels_for_teams(&self, team_ids: &[String]) -> Result<Vec<Result<Vec<Channel>>>> {
575 let listings = Graph::channels_for_teams(self, team_ids).await?;
576 Ok(listings
577 .into_iter()
578 .map(|listing| listing.map_err(Into::into))
579 .collect())
580 }
581
582 async fn chat_messages(
583 &self,
584 chat_id: &str,
585 before: Option<DateTime<Utc>>,
586 top: usize,
587 ) -> Result<RemotePage> {
588 Ok(Graph::chat_messages(self, chat_id, before, top)
589 .await?
590 .into())
591 }
592
593 async fn chat_message(&self, chat_id: &str, message_id: &str) -> Result<Message> {
594 Ok(Graph::chat_message(self, chat_id, message_id).await?)
595 }
596
597 async fn channel_messages(
598 &self,
599 team_id: &str,
600 channel_id: &str,
601 top: usize,
602 ) -> Result<RemotePage> {
603 Ok(Graph::channel_messages(self, team_id, channel_id, top)
604 .await?
605 .into())
606 }
607
608 async fn channel_messages_at(&self, next_link: &str) -> Result<RemotePage> {
609 Ok(Graph::channel_messages_at(self, next_link).await?.into())
610 }
611
612 async fn channel_message(
613 &self,
614 team_id: &str,
615 channel_id: &str,
616 message_id: &str,
617 ) -> Result<Message> {
618 Ok(Graph::channel_message(self, team_id, channel_id, message_id).await?)
619 }
620
621 async fn channel_reply(
622 &self,
623 team_id: &str,
624 channel_id: &str,
625 message_id: &str,
626 reply_id: &str,
627 ) -> Result<Message> {
628 Ok(Graph::channel_reply(self, team_id, channel_id, message_id, reply_id).await?)
629 }
630
631 async fn channel_delta(
632 &self,
633 team_id: &str,
634 channel_id: &str,
635 modified_after: Option<DateTime<Utc>>,
636 ) -> Result<DeltaPage> {
637 Ok(
638 Graph::channel_delta(self, team_id, channel_id, modified_after)
639 .await?
640 .into(),
641 )
642 }
643
644 async fn channel_delta_at(&self, link: &str) -> Result<DeltaPage> {
645 Ok(Graph::channel_delta_at(self, link).await?.into())
646 }
647
648 async fn channel_replies(
649 &self,
650 team_id: &str,
651 channel_id: &str,
652 root_ids: &[String],
653 ) -> Result<Vec<Result<Vec<Message>>>> {
654 let listings = Graph::channel_replies(self, team_id, channel_id, root_ids).await?;
655 Ok(listings
656 .into_iter()
657 .map(|listing| listing.map_err(Into::into))
658 .collect())
659 }
660
661 async fn send_chat_message(
662 &self,
663 chat_id: &str,
664 html: &str,
665 mentions: &[OutgoingMention],
666 extras: &MessageExtras,
667 ) -> Result<Message> {
668 Ok(Graph::send_chat_message(self, chat_id, html, mentions, extras).await?)
669 }
670
671 async fn send_channel_message(
672 &self,
673 team_id: &str,
674 channel_id: &str,
675 html: &str,
676 subject: Option<&str>,
677 mentions: &[OutgoingMention],
678 extras: &MessageExtras,
679 ) -> Result<Message> {
680 Ok(
681 Graph::send_channel_message(self, team_id, channel_id, html, subject, mentions, extras)
682 .await?,
683 )
684 }
685
686 async fn reply_to_channel_message(
687 &self,
688 team_id: &str,
689 channel_id: &str,
690 message_id: &str,
691 html: &str,
692 mentions: &[OutgoingMention],
693 extras: &MessageExtras,
694 ) -> Result<Message> {
695 Ok(Graph::reply_to_channel_message(
696 self, team_id, channel_id, message_id, html, mentions, extras,
697 )
698 .await?)
699 }
700
701 async fn mark_chat_read(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
702 Ok(Graph::mark_chat_read(self, chat_id, user_id, tenant_id).await?)
703 }
704
705 async fn mark_chat_unread(
706 &self,
707 chat_id: &str,
708 user_id: &str,
709 tenant_id: &str,
710 last_read_at: DateTime<Utc>,
711 ) -> Result<()> {
712 Ok(Graph::mark_chat_unread(self, chat_id, user_id, tenant_id, last_read_at).await?)
713 }
714
715 async fn hide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
716 Ok(Graph::hide_chat(self, chat_id, user_id, tenant_id).await?)
717 }
718
719 async fn unhide_chat(&self, chat_id: &str, user_id: &str, tenant_id: &str) -> Result<()> {
720 Ok(Graph::unhide_chat(self, chat_id, user_id, tenant_id).await?)
721 }
722
723 async fn remove_chat_member(&self, chat_id: &str, user_id: &str) -> Result<()> {
724 Ok(ThreadMembers::new(self.session())
725 .remove(chat_id, user_id)
726 .await?)
727 }
728
729 async fn add_chat_members(
730 &self,
731 chat_id: &str,
732 user_ids: &[String],
733 share: HistoryShare,
734 ) -> Result<()> {
735 Ok(ThreadMembers::new(self.session())
736 .add(chat_id, user_ids, share, Utc::now().timestamp_millis())
737 .await?)
738 }
739
740 async fn chat_states(&self) -> Result<Vec<ConversationState>> {
741 Ok(Conversations::new(self.session())
742 .conversation_states()
743 .await?)
744 }
745
746 async fn set_chat_muted(&self, chat_id: &str, muted: bool) -> Result<()> {
747 Ok(Conversations::new(self.session())
748 .set_alerts(chat_id, !muted)
749 .await?)
750 }
751
752 async fn set_read_horizon(&self, conversation_id: &str, horizon: &str) -> Result<()> {
753 Ok(Conversations::new(self.session())
754 .set_read_horizon(conversation_id, horizon)
755 .await?)
756 }
757
758 async fn set_channel_notifications(
759 &self,
760 channel_id: &str,
761 notifications: store::ChannelNotifications,
762 ) -> Result<()> {
763 Ok(Conversations::new(self.session())
764 .set_channel_notifications(
765 channel_id,
766 crate::folders::chatsvc_notifications(notifications),
767 )
768 .await?)
769 }
770
771 async fn send_typing(&self, conversation: &ConversationRef, active: bool) -> Result<()> {
772 Ok(Messages::new(self.session())
773 .send_typing(conversation, active)
774 .await?)
775 }
776
777 /// Teams `ackUrgentMessage`: the emotion `acks` on the message stops the urgent repeat notifications.
778 async fn ack_urgent_message(&self, chat_id: &str, message_id: &str) -> Result<()> {
779 Ok(Messages::new(self.session())
780 .set_emotion(
781 &ConversationRef::chat(chat_id),
782 message_id,
783 URGENT_ACK_EMOTION,
784 )
785 .await?)
786 }
787
788 async fn set_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
789 if let Some(key) = chatsvc::reaction_key(reaction_type) {
790 return Ok(Messages::new(self.session())
791 .set_emotion(&conversation_ref(target), target.message_id(), &key)
792 .await?);
793 }
794 Ok(Graph::set_reaction(self, target, reaction_type).await?)
795 }
796
797 async fn unset_reaction(&self, target: &MessageTarget, reaction_type: &str) -> Result<()> {
798 let keys = chatsvc::reaction_keys(reaction_type);
799 if !keys.is_empty() {
800 let keys: Vec<&str> = keys.iter().map(String::as_str).collect();
801 return Ok(Messages::new(self.session())
802 .unset_emotions(&conversation_ref(target), target.message_id(), &keys)
803 .await?);
804 }
805 Ok(Graph::unset_reaction(self, target, reaction_type).await?)
806 }
807
808 async fn edit_message(
809 &self,
810 target: &MessageTarget,
811 html: &str,
812 mentions: &[OutgoingMention],
813 extras: &MessageExtras,
814 ) -> Result<()> {
815 match chatsvc_conversation(target) {
816 Some(conversation) if mentions.is_empty() => {
817 let html = format!("{}{html}{}", extras.kept_html(), extras.files_html());
818 Ok(Messages::new(self.session())
819 .edit_message(&conversation, target.message_id(), &html)
820 .await?)
821 }
822 Some(_) => Err(Error::Unsupported(
823 "editing a channel message with mentions",
824 )),
825 None => Ok(Graph::edit_message(self, target, html, mentions, extras).await?),
826 }
827 }
828
829 async fn soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()> {
830 match chatsvc_conversation(target) {
831 Some(conversation) => Ok(Messages::new(self.session())
832 .soft_delete_message(&conversation, target.message_id())
833 .await?),
834 None => Ok(Graph::soft_delete_message(self, user_id, target).await?),
835 }
836 }
837
838 async fn undo_soft_delete_message(&self, user_id: &str, target: &MessageTarget) -> Result<()> {
839 match chatsvc_conversation(target) {
840 Some(conversation) => Ok(Messages::new(self.session())
841 .undelete_message(&conversation, target.message_id())
842 .await?),
843 None => Ok(Graph::undo_soft_delete_message(self, user_id, target).await?),
844 }
845 }
846
847 async fn create_one_on_one(&self, my_user_id: &str, user_id: &str) -> Result<Chat> {
848 Ok(Graph::create_one_on_one(self, my_user_id, user_id).await?)
849 }
850
851 async fn create_group(
852 &self,
853 my_user_id: &str,
854 user_ids: &[String],
855 topic: Option<&str>,
856 ) -> Result<Chat> {
857 Ok(Graph::create_group(self, my_user_id, user_ids, topic).await?)
858 }
859
860 async fn search_people(&self, query: &str) -> Result<Vec<User>> {
861 Ok(Graph::search_people(self, query).await?)
862 }
863
864 async fn reply_with_quote(
865 &self,
866 chat_id: &str,
867 quoted_message_id: &str,
868 html: &str,
869 mentions: &[OutgoingMention],
870 extras: &MessageExtras,
871 ) -> Result<Message> {
872 Ok(
873 Graph::reply_with_quote(self, chat_id, quoted_message_id, html, mentions, extras)
874 .await?,
875 )
876 }
877
878 async fn channel_files_folder(&self, team_id: &str, channel_id: &str) -> Result<DriveFolder> {
879 Ok(Graph::channel_files_folder(self, team_id, channel_id).await?)
880 }
881
882 async fn channel_files_root(&self, team_id: &str, channel_id: &str) -> Result<DriveEntry> {
883 Ok(Graph::channel_files_root(self, team_id, channel_id).await?)
884 }
885
886 async fn channel_tab_web_url(
887 &self,
888 team_id: &str,
889 channel_id: &str,
890 tab_id: &str,
891 ) -> Result<Option<String>> {
892 Ok(Graph::channel_tab_web_url(self, team_id, channel_id, tab_id).await?)
893 }
894
895 async fn list_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
896 Ok(Graph::list_children(self, folder).await?)
897 }
898
899 async fn create_folder(&self, parent: &DriveFolder, name: &str) -> Result<DriveEntry> {
900 Ok(Graph::create_folder(self, parent, name).await?)
901 }
902
903 async fn upload_file(
904 &self,
905 destination: &UploadDestination,
906 file_name: &str,
907 bytes: &[u8],
908 progress: &(dyn Fn(u8) + Send + Sync),
909 ) -> Result<UploadedFile> {
910 Ok(Graph::upload_file(self, destination, file_name, bytes, progress).await?)
911 }
912
913 async fn share_file(&self, file: &UploadedFile, user_ids: &[String]) -> Result<()> {
914 Ok(Graph::share_item(self, file, user_ids).await?)
915 }
916
917 async fn delete_file(&self, file: &UploadedFile) -> Result<()> {
918 Ok(Graph::delete_drive_item(self, &file.drive_id, &file.item_id).await?)
919 }
920
921 async fn resolve_share(&self, open_url: &str) -> Result<SharedFile> {
922 Ok(Graph::resolve_share(self, open_url).await?)
923 }
924
925 async fn resolve_drive_item(&self, drive_id: &str, item_id: &str) -> Result<SharedFile> {
926 Ok(Graph::resolve_drive_item(self, drive_id, item_id).await?)
927 }
928
929 async fn download_range(
930 &self,
931 download_url: &str,
932 start: u64,
933 end: Option<u64>,
934 ) -> Result<Vec<u8>> {
935 Ok(Graph::download_range(self, download_url, start, end).await?)
936 }
937
938 async fn hosted_content(&self, url: &str) -> Result<Photo> {
939 if chatsvc::is_link_image_url(url) {
940 let image = Messages::new(self.session()).link_image(url).await?;
941 return Ok(Photo {
942 bytes: image.bytes,
943 content_type: image.content_type,
944 });
945 }
946 Ok(Graph::download_hosted_content(self, url).await?)
947 }
948
949 async fn external_image(&self, url: &str) -> Result<Photo> {
950 Ok(Graph::download_external_image(self, url).await?)
951 }
952
953 async fn user_photos(&self, user_ids: &[String]) -> Result<Vec<Result<Option<Photo>>>> {
954 let photos = Graph::user_photos(self, user_ids).await?;
955 Ok(photos
956 .into_iter()
957 .map(|photo| photo.map_err(Into::into))
958 .collect())
959 }
960
961 async fn presences(&self, user_ids: &[String]) -> Result<Vec<Presence>> {
962 let found = PresenceLookup::new(self.session())
963 .presences(user_ids)
964 .await?;
965 Ok(found
966 .into_iter()
967 .map(|presence| Presence {
968 user_id: presence.user_id,
969 availability: presence.availability,
970 activity: presence.activity,
971 })
972 .collect())
973 }
974
975 async fn person_profile(&self, user_id: &str) -> Result<PersonProfile> {
976 crate::profile::load_profile(self, user_id).await
977 }
978
979 async fn bot_profiles(&self, bot_ids: &[String]) -> Result<Vec<BotProfile>> {
980 Ok(BotProfiles::new(self.session()).fetch(bot_ids).await?)
981 }
982
983 async fn subscribe_presence(
984 &self,
985 endpoint_id: &str,
986 trouter_uri: &str,
987 user_ids: &[String],
988 purge: bool,
989 ) -> Result<()> {
990 Ok(PresenceLookup::new(self.session())
991 .subscribe(endpoint_id, trouter_uri, user_ids, purge)
992 .await?)
993 }
994
995 async fn own_status(&self, user_id: &str) -> Result<PresenceStatus> {
996 Ok(PresenceService::new(self.session()).status(user_id).await?)
997 }
998
999 async fn set_availability(&self, forced: Option<&ForcedAvailability>) -> Result<()> {
1000 Ok(PresenceService::new(self.session())
1001 .set_availability(forced)
1002 .await?)
1003 }
1004
1005 async fn set_status_note(&self, note: Option<&StatusNote>) -> Result<()> {
1006 Ok(PresenceService::new(self.session()).set_note(note).await?)
1007 }
1008
1009 async fn set_work_location(
1010 &self,
1011 location: Option<(WorkLocationKind, DateTime<Utc>)>,
1012 ) -> Result<()> {
1013 Ok(PresenceService::new(self.session())
1014 .set_work_location(location)
1015 .await?)
1016 }
1017
1018 async fn consumption_horizons(&self, conversation_id: &str) -> Result<Vec<MemberHorizon>> {
1019 Ok(Receipts::new(self.session())
1020 .consumption_horizons(conversation_id)
1021 .await?)
1022 }
1023
1024 async fn forward_messages(
1025 &self,
1026 source_conversation_id: &str,
1027 target_conversation_id: &str,
1028 message_ids: &[String],
1029 comment_html: &str,
1030 ) -> Result<ForwardResult> {
1031 Ok(Messages::new(self.session())
1032 .forward_messages(
1033 source_conversation_id,
1034 target_conversation_id,
1035 message_ids,
1036 comment_html,
1037 )
1038 .await?)
1039 }
1040
1041 async fn set_saved(
1042 &self,
1043 conversation_id: &str,
1044 root_id: &str,
1045 message_id: &str,
1046 saved: bool,
1047 ) -> Result<()> {
1048 Ok(Messages::new(self.session())
1049 .set_saved(conversation_id, root_id, message_id, saved)
1050 .await?)
1051 }
1052
1053 async fn list_saved(&self) -> Result<Vec<SavedMessage>> {
1054 Ok(Messages::new(self.session()).list_saved().await?)
1055 }
1056
1057 async fn list_call_logs(&self) -> Result<Vec<CallLogEntry>> {
1058 Ok(Messages::new(self.session()).list_call_logs().await?)
1059 }
1060
1061 async fn chat_message_window(
1062 &self,
1063 chat_id: &str,
1064 anchor_id: &str,
1065 direction: WindowDirection,
1066 page_size: usize,
1067 ) -> Result<MessageWindow> {
1068 Ok(Messages::new(self.session())
1069 .message_window(chat_id, anchor_id, direction, page_size)
1070 .await?)
1071 }
1072
1073 async fn chat_messages_by_id(
1074 &self,
1075 chat_id: &str,
1076 message_ids: &[String],
1077 ) -> Result<Vec<Result<Message>>> {
1078 let messages = Graph::chat_messages_by_id(self, chat_id, message_ids).await?;
1079 Ok(messages
1080 .into_iter()
1081 .map(|message| message.map_err(Into::into))
1082 .collect())
1083 }
1084
1085 async fn chat_pins(&self, chat_id: &str) -> Result<Vec<PinnedMessage>> {
1086 Ok(Pins::new(self.session()).chat_pins(chat_id).await?)
1087 }
1088
1089 async fn pin_message(&self, chat_id: &str, message_id: &str) -> Result<()> {
1090 Ok(Pins::new(self.session())
1091 .pin_message(chat_id, message_id)
1092 .await?)
1093 }
1094
1095 async fn unpin_message(
1096 &self,
1097 chat_id: &str,
1098 message_id: &str,
1099 parent_id: Option<&str>,
1100 ) -> Result<()> {
1101 Ok(Pins::new(self.session())
1102 .unpin_message(chat_id, message_id, parent_id)
1103 .await?)
1104 }
1105
1106 async fn channel_pinned_posts(
1107 &self,
1108 team_thread_id: &str,
1109 channel_id: &str,
1110 ) -> Result<Vec<PinnedMessage>> {
1111 Ok(Pins::with_skype_token(self.session())
1112 .channel_pinned_posts(team_thread_id, channel_id)
1113 .await?)
1114 }
1115
1116 async fn set_post_pinned(
1117 &self,
1118 team_thread_id: &str,
1119 channel_id: &str,
1120 post_id: &str,
1121 pinned: bool,
1122 ) -> Result<()> {
1123 Ok(Pins::with_skype_token(self.session())
1124 .set_post_pinned(team_thread_id, channel_id, post_id, pinned)
1125 .await?)
1126 }
1127
1128 async fn mention_activities(&self) -> Result<Vec<MentionActivity>> {
1129 Ok(ActivityFeed::new(self.session()).mentions().await?)
1130 }
1131
1132 async fn app_consumption_horizon(&self) -> Result<AppConsumptionHorizon> {
1133 let properties = UserSettings::new(self.session()).properties().await?;
1134 Ok(parse_app_consumption_horizon(&properties))
1135 }
1136
1137 async fn mark_all_channels_read(&self, now_ms: i64) -> Result<AppConsumptionHorizon> {
1138 Ok(UserSettings::new(self.session())
1139 .mark_all_channels_read(now_ms)
1140 .await?)
1141 }
1142
1143 async fn chat_apps(&self, chat_id: &str) -> Result<Vec<ChatApp>> {
1144 Ok(CardActions::new(self.session()).chat_apps(chat_id).await?)
1145 }
1146
1147 async fn invoke_card(&self, invoke: InvokeRequest) -> Result<InvokeResponse> {
1148 Ok(CardActions::new(self.session()).invoke(invoke).await?)
1149 }
1150
1151 async fn message_links(
1152 &self,
1153 conversation: &ConversationRef,
1154 page_size: usize,
1155 ) -> Result<Vec<MessageLinks>> {
1156 Ok(Messages::new(self.session())
1157 .list_message_links(conversation, page_size)
1158 .await?)
1159 }
1160
1161 async fn message_emotions(
1162 &self,
1163 conversation: &ConversationRef,
1164 newest_message_id: &str,
1165 page_size: usize,
1166 ) -> Result<Vec<MessageEmotions>> {
1167 Ok(Messages::new(self.session())
1168 .message_emotions(
1169 &conversation.conversation_id(),
1170 newest_message_id,
1171 page_size,
1172 )
1173 .await?)
1174 }
1175
1176 async fn set_message_links(&self, target: &MessageTarget, links_json: &str) -> Result<()> {
1177 Ok(Messages::new(self.session())
1178 .set_links(&conversation_ref(target), target.message_id(), links_json)
1179 .await?)
1180 }
1181
1182 async fn link_info(&self, url: &str) -> Result<LinkInfo> {
1183 Ok(Messages::new(self.session()).link_info(url).await?)
1184 }
1185
1186 async fn message_languages(
1187 &self,
1188 conversation: &ConversationRef,
1189 page_size: usize,
1190 ) -> Result<Vec<MessageLanguage>> {
1191 Ok(Messages::new(self.session())
1192 .list_language_stamps(conversation, page_size)
1193 .await?)
1194 }
1195
1196 async fn translate_chat_messages(
1197 &self,
1198 chat_id: &str,
1199 to_language: &str,
1200 messages: &[TranslateRequest],
1201 trigger: &TranslationTrigger,
1202 ) -> Result<Vec<Translation>> {
1203 Ok(Translator::new(self.session())
1204 .translate_chat(chat_id, to_language, messages, trigger)
1205 .await?)
1206 }
1207
1208 async fn translate_channel_messages(
1209 &self,
1210 team_id: &str,
1211 channel_id: &str,
1212 root_id: &str,
1213 to_language: &str,
1214 messages: &[TranslateRequest],
1215 trigger: &TranslationTrigger,
1216 ) -> Result<Vec<Translation>> {
1217 Ok(Translator::new(self.session())
1218 .translate_channel(team_id, channel_id, root_id, to_language, messages, trigger)
1219 .await?)
1220 }
1221
1222 async fn translation_languages(&self, locale: &str) -> Result<Vec<Language>> {
1223 Ok(Translator::new(self.session()).languages(locale).await?)
1224 }
1225
1226 async fn language_settings(&self) -> Result<LanguageSettings> {
1227 Ok(LanguageSettingsClient::new(self.session()).read().await?)
1228 }
1229
1230 async fn recording_policy(&self) -> Result<RecordingPolicy> {
1231 Ok(LanguageSettingsClient::new(self.session())
1232 .read_recording_policy()
1233 .await?)
1234 }
1235
1236 async fn allow_priority_messages(&self) -> Result<bool> {
1237 Ok(LanguageSettingsClient::new(self.session())
1238 .read_allow_priority_messages()
1239 .await?)
1240 }
1241
1242 async fn patch_language_settings(&self, patch: serde_json::Value) -> Result<()> {
1243 Ok(LanguageSettingsClient::new(self.session())
1244 .patch(patch)
1245 .await?)
1246 }
1247
1248 async fn sound_settings(&self) -> Result<SoundSettings> {
1249 Ok(SoundSettingsClient::new(self.session()).read().await?)
1250 }
1251
1252 async fn save_sound_settings(
1253 &self,
1254 user_mri: &str,
1255 previous: &SoundSettings,
1256 updated: &SoundSettings,
1257 ) -> Result<()> {
1258 Ok(SoundSettingsClient::new(self.session())
1259 .write(user_mri, previous, updated)
1260 .await?)
1261 }
1262
1263 async fn search_gifs(&self, query: &str) -> Result<Vec<Gif>> {
1264 Ok(Gifs::new(self.session()).search(query).await?)
1265 }
1266
1267 async fn server_search_init(
1268 &self,
1269 identity: &SearchIdentity,
1270 search_session: &SearchSession,
1271 ) -> Result<()> {
1272 Ok(SubstrateSearch::new(self.session(), identity.clone())
1273 .init(search_session)
1274 .await?)
1275 }
1276
1277 async fn server_suggestions(
1278 &self,
1279 identity: &SearchIdentity,
1280 search_session: &SearchSession,
1281 text: &str,
1282 ) -> Result<Suggestions> {
1283 Ok(SubstrateSearch::new(self.session(), identity.clone())
1284 .suggestions(search_session, text)
1285 .await?)
1286 }
1287
1288 async fn server_query(
1289 &self,
1290 identity: &SearchIdentity,
1291 search_session: &SearchSession,
1292 request: &QueryRequest,
1293 ) -> Result<QueryResults> {
1294 Ok(SubstrateSearch::new(self.session(), identity.clone())
1295 .query(search_session, request)
1296 .await?)
1297 }
1298
1299 async fn create_scheduled(
1300 &self,
1301 inner_thread_id: &str,
1302 html: &str,
1303 send_at: DateTime<Utc>,
1304 display_name: &str,
1305 ) -> Result<ScheduledDraft> {
1306 Ok(ScheduledDrafts::new(self.session())
1307 .create(inner_thread_id, html, send_at, display_name)
1308 .await?)
1309 }
1310
1311 async fn scheduled_drafts(&self) -> Result<Vec<ScheduledDraft>> {
1312 Ok(ScheduledDrafts::new(self.session()).list().await?)
1313 }
1314
1315 async fn update_scheduled(
1316 &self,
1317 draft: &ScheduledDraft,
1318 html: &str,
1319 display_name: &str,
1320 ) -> Result<ScheduledDraft> {
1321 Ok(ScheduledDrafts::new(self.session())
1322 .update(draft, html, display_name)
1323 .await?)
1324 }
1325
1326 async fn cancel_scheduled(&self, draft_id: &str) -> Result<()> {
1327 Ok(ScheduledDrafts::new(self.session())
1328 .cancel(draft_id)
1329 .await?)
1330 }
1331}
1332
1333fn chatsvc_conversation(target: &MessageTarget) -> Option<ConversationRef> {
1334 match target {
1335 MessageTarget::Chat { .. } => CHATSVC_CHAT_WRITES.then(|| conversation_ref(target)),
1336 MessageTarget::Channel { .. } => Some(conversation_ref(target)),
1337 }
1338}
1339
1340fn conversation_ref(target: &MessageTarget) -> ConversationRef {
1341 match target {
1342 MessageTarget::Chat { chat_id, .. } => ConversationRef::chat(chat_id),
1343 MessageTarget::Channel {
1344 channel_id,
1345 root_id: None,
1346 ..
1347 } => ConversationRef::channel_root(channel_id),
1348 MessageTarget::Channel {
1349 channel_id,
1350 root_id: Some(root_id),
1351 ..
1352 } => ConversationRef::channel_reply(channel_id, root_id),
1353 }
1354}
1355
1356impl From<graph::Page<Message>> for RemotePage {
1357 fn from(page: graph::Page<Message>) -> Self {
1358 RemotePage {
1359 items: page.items,
1360 next_link: page.next_link,
1361 }
1362 }
1363}
1364
1365impl From<graph::Page<Message>> for DeltaPage {
1366 fn from(page: graph::Page<Message>) -> Self {
1367 DeltaPage {
1368 items: page.items,
1369 next_link: page.next_link,
1370 delta_link: page.delta_link,
1371 }
1372 }
1373}
1374
1375impl From<graph::Page<Chat>> for ChatsPage {
1376 fn from(page: graph::Page<Chat>) -> Self {
1377 ChatsPage {
1378 items: page.items,
1379 next_link: page.next_link,
1380 }
1381 }
1382}
1383
1384#[cfg(test)]
1385mod tests {
1386 use super::*;
1387
1388 #[test]
1389 fn channel_targets_route_to_chatsvc() {
1390 let root = MessageTarget::channel("t", "19:c@thread.tacv2", "m1", None);
1391 let reply = MessageTarget::channel("t", "19:c@thread.tacv2", "r1", Some("m1"));
1392 assert_eq!(
1393 chatsvc_conversation(&root),
1394 Some(ConversationRef::channel_root("19:c@thread.tacv2"))
1395 );
1396 assert_eq!(
1397 chatsvc_conversation(&reply),
1398 Some(ConversationRef::channel_reply("19:c@thread.tacv2", "m1"))
1399 );
1400 }
1401
1402 #[test]
1403 fn reactions_reach_chats_regardless_of_the_feature_switch() {
1404 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
1405 assert_eq!(
1406 conversation_ref(&chat),
1407 ConversationRef::chat("19:a@thread.v2")
1408 );
1409 }
1410
1411 #[test]
1412 fn chats_follow_the_feature_switch() {
1413 let chat = MessageTarget::chat("19:a@thread.v2", "m1");
1414 assert_eq!(chatsvc_conversation(&chat).is_some(), CHATSVC_CHAT_WRITES);
1415 }
1416}