mirror of
https://github.com/chatmail/core.git
synced 2026-05-18 22:36:29 +03:00
api(rust, jsonrpc): add get_message_read_receipt_count method (#7732)
closes #7728
This commit is contained in:
@@ -23,8 +23,8 @@ use deltachat::ephemeral::Timer;
|
|||||||
use deltachat::imex;
|
use deltachat::imex;
|
||||||
use deltachat::location;
|
use deltachat::location;
|
||||||
use deltachat::message::{
|
use deltachat::message::{
|
||||||
self, delete_msgs_ex, get_existing_msg_ids, get_msg_read_receipts, markseen_msgs, Message,
|
self, delete_msgs_ex, get_existing_msg_ids, get_msg_read_receipt_count, get_msg_read_receipts,
|
||||||
MessageState, MsgId, Viewtype,
|
markseen_msgs, Message, MessageState, MsgId, Viewtype,
|
||||||
};
|
};
|
||||||
use deltachat::peer_channels::{
|
use deltachat::peer_channels::{
|
||||||
leave_webxdc_realtime, send_webxdc_realtime_advertisement, send_webxdc_realtime_data,
|
leave_webxdc_realtime, send_webxdc_realtime_advertisement, send_webxdc_realtime_data,
|
||||||
@@ -1434,6 +1434,18 @@ impl CommandApi {
|
|||||||
MessageInfo::from_msg_id(&ctx, MsgId::new(message_id)).await
|
MessageInfo::from_msg_id(&ctx, MsgId::new(message_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns count of read receipts on message.
|
||||||
|
///
|
||||||
|
/// This view count is meant as a feedback measure for the channel owner only.
|
||||||
|
async fn get_message_read_receipt_count(
|
||||||
|
&self,
|
||||||
|
account_id: u32,
|
||||||
|
message_id: u32,
|
||||||
|
) -> Result<usize> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
|
get_msg_read_receipt_count(&ctx, MsgId::new(message_id)).await
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns contacts that sent read receipts and the time of reading.
|
/// Returns contacts that sent read receipts and the time of reading.
|
||||||
async fn get_message_read_receipts(
|
async fn get_message_read_receipts(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ class Message:
|
|||||||
read_receipts = self._rpc.get_message_read_receipts(self.account.id, self.id)
|
read_receipts = self._rpc.get_message_read_receipts(self.account.id, self.id)
|
||||||
return [AttrDict(read_receipt) for read_receipt in read_receipts]
|
return [AttrDict(read_receipt) for read_receipt in read_receipts]
|
||||||
|
|
||||||
|
def get_read_receipt_count(self) -> int:
|
||||||
|
"""
|
||||||
|
Returns count of read receipts on message.
|
||||||
|
|
||||||
|
This view count is meant as a feedback measure for the channel owner only.
|
||||||
|
"""
|
||||||
|
return self._rpc.get_message_read_receipt_count(self.account.id, self.id)
|
||||||
|
|
||||||
def get_reactions(self) -> Optional[AttrDict]:
|
def get_reactions(self) -> Optional[AttrDict]:
|
||||||
"""Get message reactions."""
|
"""Get message reactions."""
|
||||||
reactions = self._rpc.get_message_reactions(self.account.id, self.id)
|
reactions = self._rpc.get_message_reactions(self.account.id, self.id)
|
||||||
|
|||||||
@@ -930,6 +930,9 @@ def test_read_receipt(acfactory):
|
|||||||
assert len(read_receipts) == 1
|
assert len(read_receipts) == 1
|
||||||
assert read_receipts[0].contact_id == alice_contact_bob.id
|
assert read_receipts[0].contact_id == alice_contact_bob.id
|
||||||
|
|
||||||
|
read_receipt_cnt = read_msg.get_read_receipt_count()
|
||||||
|
assert read_receipt_cnt == 1
|
||||||
|
|
||||||
|
|
||||||
def test_get_http_response(acfactory):
|
def test_get_http_response(acfactory):
|
||||||
alice = acfactory.new_configured_account()
|
alice = acfactory.new_configured_account()
|
||||||
|
|||||||
@@ -1506,6 +1506,16 @@ pub async fn get_msg_read_receipts(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns count of read receipts on message.
|
||||||
|
///
|
||||||
|
/// This view count is meant as a feedback measure for the channel owner only.
|
||||||
|
pub async fn get_msg_read_receipt_count(context: &Context, msg_id: MsgId) -> Result<usize> {
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.count("SELECT COUNT(*) FROM msgs_mdns WHERE msg_id=?", (msg_id,))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn guess_msgtype_from_suffix(msg: &Message) -> Option<(Viewtype, &'static str)> {
|
pub(crate) fn guess_msgtype_from_suffix(msg: &Message) -> Option<(Viewtype, &'static str)> {
|
||||||
msg.param
|
msg.param
|
||||||
.get(Param::Filename)
|
.get(Param::Filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user