mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
api: jsonrpc: new MessageReadReceipt type and get_message_read_receipts(account_id, message_id) jsonrpc method
This commit is contained in:
@@ -4,6 +4,7 @@ use std::{collections::HashMap, str::FromStr};
|
|||||||
|
|
||||||
use anyhow::{anyhow, bail, ensure, Context, Result};
|
use anyhow::{anyhow, bail, ensure, Context, Result};
|
||||||
pub use deltachat::accounts::Accounts;
|
pub use deltachat::accounts::Accounts;
|
||||||
|
use deltachat::message::get_msg_read_receipts;
|
||||||
use deltachat::qr::Qr;
|
use deltachat::qr::Qr;
|
||||||
use deltachat::{
|
use deltachat::{
|
||||||
chat::{
|
chat::{
|
||||||
@@ -43,8 +44,7 @@ use types::chat::FullChat;
|
|||||||
use types::contact::ContactObject;
|
use types::contact::ContactObject;
|
||||||
use types::events::Event;
|
use types::events::Event;
|
||||||
use types::http::HttpResponse;
|
use types::http::HttpResponse;
|
||||||
use types::message::MessageData;
|
use types::message::{MessageData, MessageObject, MessageReadReceipt};
|
||||||
use types::message::MessageObject;
|
|
||||||
use types::provider_info::ProviderInfo;
|
use types::provider_info::ProviderInfo;
|
||||||
use types::reactions::JSONRPCReactions;
|
use types::reactions::JSONRPCReactions;
|
||||||
use types::webxdc::WebxdcMessageInfo;
|
use types::webxdc::WebxdcMessageInfo;
|
||||||
@@ -1118,6 +1118,24 @@ impl CommandApi {
|
|||||||
get_msg_info(&ctx, MsgId::new(message_id)).await
|
get_msg_info(&ctx, MsgId::new(message_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns contacts that sent read receipts and the time of reading.
|
||||||
|
async fn get_message_read_receipts(
|
||||||
|
&self,
|
||||||
|
account_id: u32,
|
||||||
|
message_id: u32,
|
||||||
|
) -> Result<Vec<MessageReadReceipt>> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
|
let receipts = get_msg_read_receipts(&ctx, MsgId::new(message_id))
|
||||||
|
.await?
|
||||||
|
.iter()
|
||||||
|
.map(|(contact_id, ts)| MessageReadReceipt {
|
||||||
|
contact_id: contact_id.to_u32(),
|
||||||
|
timestamp: *ts,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Ok(receipts)
|
||||||
|
}
|
||||||
|
|
||||||
/// Asks the core to start downloading a message fully.
|
/// Asks the core to start downloading a message fully.
|
||||||
/// This function is typically called when the user hits the "Download" button
|
/// This function is typically called when the user hits the "Download" button
|
||||||
/// that is shown by the UI in case `download_state` is `'Available'` or `'Failure'`
|
/// that is shown by the UI in case `download_state` is `'Available'` or `'Failure'`
|
||||||
|
|||||||
@@ -536,3 +536,10 @@ pub struct MessageData {
|
|||||||
pub override_sender_name: Option<String>,
|
pub override_sender_name: Option<String>,
|
||||||
pub quoted_message_id: Option<u32>,
|
pub quoted_message_id: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, TypeDef)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct MessageReadReceipt {
|
||||||
|
pub contact_id: u32,
|
||||||
|
pub timestamp: i64,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user