Skip to main content

ferogram/client/
settings.rs

1/*
2 * Copyright (c) 2026 Ankit Chaubey <ankitchaubey.dev@gmail.com>
3 * https://github.com/ankit-chaubey
4 *
5 * Project: ferogram
6 * Website: https://ferogram.dev
7 *
8 * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9 * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10 * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
11 * This file may not be copied, modified, or distributed except according
12 * to those terms.
13 */
14
15use crate::*;
16#[allow(unused_imports)]
17use crate::{
18    InputMessage, InvocationError, PeerRef,
19    dialog::{Dialog, DialogIter, MessageIter},
20    inline_iter, media, participants, search, update,
21};
22use ferogram_tl_types::{Cursor, Deserializable};
23
24impl Client {
25    /// Mark all unread reactions in a chat as read.
26    pub async fn read_reactions(&self, peer: impl Into<PeerRef>) -> Result<(), InvocationError> {
27        let peer = peer.into().resolve(self).await?;
28        let input_peer = self.inner.peer_cache.read().await.peer_to_input(&peer)?;
29        let req = tl::functions::messages::ReadReactions {
30            peer: input_peer,
31            top_msg_id: None,
32            saved_peer_id: None,
33        };
34        self.rpc_write(&req).await
35    }
36
37    /// Clear the recent reactions list shown in the reaction picker.
38    pub async fn clear_recent_reactions(&self) -> Result<(), InvocationError> {
39        let req = tl::functions::messages::ClearRecentReactions {};
40        self.rpc_write(&req).await
41    }
42
43    /// Get the approximate number of online members in a group or channel.
44    pub async fn get_online_count(&self, peer: impl Into<PeerRef>) -> Result<i32, InvocationError> {
45        let peer = peer.into().resolve(self).await?;
46        let input_peer = self.inner.peer_cache.read().await.peer_to_input(&peer)?;
47        let req = tl::functions::messages::GetOnlines { peer: input_peer };
48        let body: Vec<u8> = self.rpc_call_raw(&req).await?;
49        let mut cur = Cursor::from_slice(&body);
50        let tl::enums::ChatOnlines::ChatOnlines(result) =
51            tl::enums::ChatOnlines::deserialize(&mut cur)?;
52        Ok(result.onlines)
53    }
54}