Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

closes #7728

@Simon-Laux Simon-Laux changed the title api(rust, jsonrpc): add get_msg_read_receipt_count method api(rust, jsonrpc): add get_message_read_receipt_count method Jan 16, 2026
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,))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no constraints on the msgs_mdns table, so multiple MDNs from the same contact are possible, e.g. sent from multiple devices. Probably we want to count unique contacts here

Copy link
Contributor

@r10s r10s Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that checked on adding the record? i cannot remember having seen multiple read-receipt from ine contact, knowing they have multiple devices

if so, we probably want to fix it on incoming MDNs, not here

ftr, we only recently added more detailed constraints, most columns do not have them, even if they could

assert read_receipts[0].contact_id == alice_contact_bob.id

read_receipt_cnt = read_msg.get_read_receipt_count()
assert read_receipt_cnt == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to check that it's 0 initially


/// Returns count of read receipts on message.
///
/// This view count is meant as a feedback measure for the channel owner only.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This view count is meant as a feedback measure for the channel owner only.
/// This view count is meant as a feedback measure for the message sender only.

It should be UIs' decision where to use this function, it actually works not only for channels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

channels: define an api to get the view count

4 participants