1use super::*;
4
5impl<Context> Client<Context>
6where
7 Context: XmtpSharedContext,
8{
9 #[tracing::instrument(skip_all)]
12 pub async fn sync_welcomes(&self) -> Result<Vec<MlsGroup<Context>>, GroupError> {
13 self.ensure_identity_ready::<GroupError>()?;
14 WelcomeService::new(self.context.clone())
15 .sync_welcomes()
16 .await
17 .map_err(|error| self.context.server_configuration().blocked_or(error))
18 }
19
20 #[tracing::instrument(err, skip_all, fields(operation = "sync_all_groups"))]
23 pub async fn sync_all_groups(
24 &self,
25 groups: Vec<MlsGroup<Context>>,
26 ) -> Result<GroupSyncSummary, GroupError> {
27 self.ensure_identity_ready::<GroupError>()?;
28 WelcomeService::new(self.context.clone())
29 .sync_all_groups(groups)
30 .await
31 .map_err(|error| self.context.server_configuration().blocked_or(error))
32 }
33
34 #[xmtp_common::mls_span]
37 pub async fn sync_all_welcomes_and_groups(
38 &self,
39 consent_states: Option<Vec<ConsentState>>,
40 ) -> Result<GroupSyncSummary, GroupError> {
41 self.ensure_identity_ready::<GroupError>()?;
42 WelcomeService::new(self.context.clone())
43 .sync_all_welcomes_and_groups(consent_states)
44 .await
45 .map_err(|error| self.context.server_configuration().blocked_or(error))
46 }
47
48 pub async fn unstick_paused_groups(&self) -> Result<usize, GroupError> {
58 self.ensure_identity_ready::<GroupError>()?;
59 WelcomeService::new(self.context.clone())
60 .unstick_paused_groups()
61 .await
62 }
63
64 pub async fn sync_all_welcomes_and_device_sync_groups(
65 &self,
66 ) -> Result<GroupSyncSummary, ClientError> {
67 self.sync_welcomes().await?;
68 self.sync_all_device_sync_groups().await
69 }
70
71 pub async fn sync_all_device_sync_groups(&self) -> Result<GroupSyncSummary, ClientError> {
72 let groups = self
73 .context
74 .db()
75 .all_sync_groups()?
76 .into_iter()
77 .map(|g| {
78 MlsGroup::new(
79 self.context.clone(),
80 g.id,
81 g.dm_id,
82 g.conversation_type,
83 g.created_at_ns,
84 )
85 })
86 .collect();
87
88 Ok(self.sync_all_groups(groups).await?)
89 }
90}