mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
fix: mark contact request messages as seen on IMAP
This commit is contained in:
@@ -8,7 +8,7 @@ from unittest.mock import MagicMock
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from deltachat_rpc_client import Contact, EventType, Message, events
|
from deltachat_rpc_client import Contact, EventType, Message, events
|
||||||
from deltachat_rpc_client.const import DownloadState
|
from deltachat_rpc_client.const import DownloadState, MessageState
|
||||||
from deltachat_rpc_client.direct_imap import DirectImap
|
from deltachat_rpc_client.direct_imap import DirectImap
|
||||||
from deltachat_rpc_client.rpc import JsonRpcError
|
from deltachat_rpc_client.rpc import JsonRpcError
|
||||||
|
|
||||||
@@ -584,3 +584,32 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
|
|||||||
#
|
#
|
||||||
# Message may be a private reply, so we assign it to 1:1 chat with Alice.
|
# Message may be a private reply, so we assign it to 1:1 chat with Alice.
|
||||||
assert snapshot.chat == bob_chat_alice
|
assert snapshot.chat == bob_chat_alice
|
||||||
|
|
||||||
|
|
||||||
|
def test_markseen_contact_request(acfactory, tmp_path):
|
||||||
|
"""
|
||||||
|
Test that seen status is synchronized for contact request messages
|
||||||
|
even though read receipt is not sent.
|
||||||
|
"""
|
||||||
|
alice, bob = acfactory.get_online_accounts(2)
|
||||||
|
|
||||||
|
# Bob sets up a second device.
|
||||||
|
bob.export_backup(tmp_path)
|
||||||
|
files = list(tmp_path.glob("*.tar"))
|
||||||
|
bob2 = acfactory.get_unconfigured_account()
|
||||||
|
bob2.import_backup(files[0])
|
||||||
|
bob2.start_io()
|
||||||
|
|
||||||
|
alice_chat_bob = alice.create_chat(bob)
|
||||||
|
alice_chat_bob.send_text("Hello Bob!")
|
||||||
|
|
||||||
|
message = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id)
|
||||||
|
message2 = bob2.get_message_by_id(bob2.wait_for_incoming_msg_event().msg_id)
|
||||||
|
assert message2.get_snapshot().state == MessageState.IN_FRESH
|
||||||
|
|
||||||
|
message.mark_seen()
|
||||||
|
while True:
|
||||||
|
event = bob2.wait_for_event()
|
||||||
|
if event.kind == EventType.MSGS_NOTICED:
|
||||||
|
break
|
||||||
|
assert message2.get_snapshot().state == MessageState.IN_SEEN
|
||||||
|
|||||||
@@ -1643,9 +1643,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
|
|||||||
_curr_ephemeral_timer,
|
_curr_ephemeral_timer,
|
||||||
) in msgs
|
) in msgs
|
||||||
{
|
{
|
||||||
if curr_blocked == Blocked::Not
|
if curr_state == MessageState::InFresh || curr_state == MessageState::InNoticed {
|
||||||
&& (curr_state == MessageState::InFresh || curr_state == MessageState::InNoticed)
|
|
||||||
{
|
|
||||||
update_msg_state(context, id, MessageState::InSeen).await?;
|
update_msg_state(context, id, MessageState::InSeen).await?;
|
||||||
info!(context, "Seen message {}.", id);
|
info!(context, "Seen message {}.", id);
|
||||||
|
|
||||||
@@ -1657,7 +1655,11 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
|
|||||||
// "Group left by me", a read receipt will quote "Group left by <name>", and the name can
|
// "Group left by me", a read receipt will quote "Group left by <name>", and the name can
|
||||||
// be a display name stored in address book rather than the name sent in the From field by
|
// be a display name stored in address book rather than the name sent in the From field by
|
||||||
// the user.
|
// the user.
|
||||||
if curr_param.get_bool(Param::WantsMdn).unwrap_or_default()
|
//
|
||||||
|
// We also don't send read receipts for contact requests.
|
||||||
|
// Read receipts will not be sent even after accepting the chat.
|
||||||
|
if curr_blocked == Blocked::Not
|
||||||
|
&& curr_param.get_bool(Param::WantsMdn).unwrap_or_default()
|
||||||
&& curr_param.get_cmd() == SystemMessage::Unknown
|
&& curr_param.get_cmd() == SystemMessage::Unknown
|
||||||
{
|
{
|
||||||
let mdns_enabled = context.get_config_bool(Config::MdnsEnabled).await?;
|
let mdns_enabled = context.get_config_bool(Config::MdnsEnabled).await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user