rive_http/users/
direct_messaging.rs

1use crate::prelude::*;
2use rive_models::channel::Channel;
3
4impl Client {
5    /// This fetches your direct messages, including any DM and group DM conversations.
6    pub async fn fetch_direct_message_channels(&self) -> Result<Vec<Channel>> {
7        Ok(self
8            .client
9            .get(ep!(self, "/users/dms"))
10            .auth(&self.authentication)
11            .send()
12            .await?
13            .process_error()
14            .await?
15            .json()
16            .await?)
17    }
18
19    /// Open a DM with another user.
20    ///
21    /// If the target is oneself, a saved messages channel is returned.
22    pub async fn open_direct_message(&self, id: impl Into<String>) -> Result<Channel> {
23        Ok(self
24            .client
25            .get(ep!(self, "/users/{}/dm", id.into()))
26            .auth(&self.authentication)
27            .send()
28            .await?
29            .process_error()
30            .await?
31            .json()
32            .await?)
33    }
34}