mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
@@ -82,6 +82,14 @@ class Chat(object):
|
|||||||
"""
|
"""
|
||||||
return not lib.dc_chat_is_unpromoted(self._dc_chat)
|
return not lib.dc_chat_is_unpromoted(self._dc_chat)
|
||||||
|
|
||||||
|
def can_send(self):
|
||||||
|
"""Check if messages can be sent to a give chat.
|
||||||
|
This is not true eg. for the deaddrop or for the device-talk
|
||||||
|
|
||||||
|
:returns: True if the chat is writable, False otherwise
|
||||||
|
"""
|
||||||
|
return lib.dc_chat_can_send(self._dc_chat)
|
||||||
|
|
||||||
def is_protected(self):
|
def is_protected(self):
|
||||||
""" return True if this chat is a protected chat.
|
""" return True if this chat is a protected chat.
|
||||||
|
|
||||||
|
|||||||
@@ -1032,6 +1032,16 @@ class TestOnlineAccount:
|
|||||||
assert msg_in.text == text2
|
assert msg_in.text == text2
|
||||||
assert ac1.get_config("addr") in [x.addr for x in msg_in.chat.get_contacts()]
|
assert ac1.get_config("addr") in [x.addr for x in msg_in.chat.get_contacts()]
|
||||||
|
|
||||||
|
def test_no_draft_if_cant_send(self, acfactory):
|
||||||
|
"""Tests that no quote can be set if the user can't send to this chat"""
|
||||||
|
ac1 = acfactory.get_one_online_account()
|
||||||
|
device_chat = ac1.get_device_chat()
|
||||||
|
msg = Message.new_empty(ac1, "text")
|
||||||
|
device_chat.set_draft(msg)
|
||||||
|
|
||||||
|
assert not device_chat.can_send()
|
||||||
|
assert device_chat.get_draft() is None
|
||||||
|
|
||||||
def test_prefer_encrypt(self, acfactory, lp):
|
def test_prefer_encrypt(self, acfactory, lp):
|
||||||
"""Test quorum rule for encryption preference in 1:1 and group chat."""
|
"""Test quorum rule for encryption preference in 1:1 and group chat."""
|
||||||
ac1, ac2, ac3 = acfactory.get_many_online_accounts(3)
|
ac1, ac2, ac3 = acfactory.get_many_online_accounts(3)
|
||||||
|
|||||||
@@ -460,6 +460,12 @@ impl ChatId {
|
|||||||
msg.param.set(Param::File, blob.as_name());
|
msg.param.set(Param::File, blob.as_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let chat = Chat::load_from_db(context, self).await?;
|
||||||
|
if !chat.can_send() {
|
||||||
|
bail!("Can't set a draft: Can't send");
|
||||||
|
}
|
||||||
|
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
|
|||||||
Reference in New Issue
Block a user