mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
feat: add 'group created instructions' as info message (#4916)
Before, it was shown by UI when the chat is empty, however, in case of verified groups, this is never the case any longer as the 'e2ee now guaranteed' is always added.
This commit is contained in:
@@ -7275,6 +7275,11 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
/// Used in info messages.
|
/// Used in info messages.
|
||||||
#define DC_STR_CHAT_PROTECTION_DISABLED 171
|
#define DC_STR_CHAT_PROTECTION_DISABLED 171
|
||||||
|
|
||||||
|
/// "Others will only see this group after you sent a first message."
|
||||||
|
///
|
||||||
|
/// Used as the first info messages in newly created groups.
|
||||||
|
#define DC_STR_NEW_GROUP_SEND_FIRST_MESSAGE 172
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ module.exports = {
|
|||||||
DC_STR_MSGGRPNAME: 15,
|
DC_STR_MSGGRPNAME: 15,
|
||||||
DC_STR_MSGLOCATIONDISABLED: 65,
|
DC_STR_MSGLOCATIONDISABLED: 65,
|
||||||
DC_STR_MSGLOCATIONENABLED: 64,
|
DC_STR_MSGLOCATIONENABLED: 64,
|
||||||
|
DC_STR_NEW_GROUP_SEND_FIRST_MESSAGE: 172,
|
||||||
DC_STR_NOMESSAGES: 1,
|
DC_STR_NOMESSAGES: 1,
|
||||||
DC_STR_NOT_CONNECTED: 121,
|
DC_STR_NOT_CONNECTED: 121,
|
||||||
DC_STR_NOT_SUPPORTED_BY_PROVIDER: 113,
|
DC_STR_NOT_SUPPORTED_BY_PROVIDER: 113,
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ export enum C {
|
|||||||
DC_STR_MSGGRPNAME = 15,
|
DC_STR_MSGGRPNAME = 15,
|
||||||
DC_STR_MSGLOCATIONDISABLED = 65,
|
DC_STR_MSGLOCATIONDISABLED = 65,
|
||||||
DC_STR_MSGLOCATIONENABLED = 64,
|
DC_STR_MSGLOCATIONENABLED = 64,
|
||||||
|
DC_STR_NEW_GROUP_SEND_FIRST_MESSAGE = 172,
|
||||||
DC_STR_NOMESSAGES = 1,
|
DC_STR_NOMESSAGES = 1,
|
||||||
DC_STR_NOT_CONNECTED = 121,
|
DC_STR_NOT_CONNECTED = 121,
|
||||||
DC_STR_NOT_SUPPORTED_BY_PROVIDER = 113,
|
DC_STR_NOT_SUPPORTED_BY_PROVIDER = 113,
|
||||||
|
|||||||
@@ -667,9 +667,9 @@ describe('Offline Tests with unconfigured account', function () {
|
|||||||
|
|
||||||
const lot = chatList.getSummary(0)
|
const lot = chatList.getSummary(0)
|
||||||
strictEqual(lot.getId(), 0, 'lot has no id')
|
strictEqual(lot.getId(), 0, 'lot has no id')
|
||||||
strictEqual(lot.getState(), C.DC_STATE_UNDEFINED, 'correct state')
|
strictEqual(lot.getState(), C.DC_STATE_IN_NOTICED, 'correct state')
|
||||||
|
|
||||||
const text = 'No messages.'
|
const text = 'Others will only see this group after you sent a first message.'
|
||||||
context.createGroupChat('groupchat1111')
|
context.createGroupChat('groupchat1111')
|
||||||
chatList = context.getChatList(0, 'groupchat1111', null)
|
chatList = context.getChatList(0, 'groupchat1111', null)
|
||||||
strictEqual(
|
strictEqual(
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ def test_forward_messages(acfactory, lp):
|
|||||||
lp.sec("ac2: check new chat has a forwarded message")
|
lp.sec("ac2: check new chat has a forwarded message")
|
||||||
assert chat3.is_promoted()
|
assert chat3.is_promoted()
|
||||||
messages = chat3.get_messages()
|
messages = chat3.get_messages()
|
||||||
assert len(messages) == 1
|
assert len(messages) == 2
|
||||||
msg = messages[-1]
|
msg = messages[-1]
|
||||||
assert msg.is_forwarded()
|
assert msg.is_forwarded()
|
||||||
ac2.delete_messages(messages)
|
ac2.delete_messages(messages)
|
||||||
@@ -1957,7 +1957,7 @@ def test_system_group_msg_from_blocked_user(acfactory, lp):
|
|||||||
chat_on_ac2.send_text("This will arrive")
|
chat_on_ac2.send_text("This will arrive")
|
||||||
msg = ac1._evtracker.wait_next_incoming_message()
|
msg = ac1._evtracker.wait_next_incoming_message()
|
||||||
assert msg.text == "This will arrive"
|
assert msg.text == "This will arrive"
|
||||||
message_texts = [m.text for m in chat_on_ac1.get_messages()]
|
message_texts = [m.text for m in chat_on_ac1.get_messages() if not m.is_system_message()]
|
||||||
assert len(message_texts) == 2
|
assert len(message_texts) == 2
|
||||||
assert "First group message" in message_texts
|
assert "First group message" in message_texts
|
||||||
assert "This will arrive" in message_texts
|
assert "This will arrive" in message_texts
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def wait_msgs_changed(account, msgs_list):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
account.log(f"waiting mismatch data1={data1} data2={data2}")
|
account.log(f"waiting mismatch data1={data1} data2={data2}")
|
||||||
return ev.data1, ev.data2
|
return ev.data2
|
||||||
|
|
||||||
|
|
||||||
class TestOnlineInCreation:
|
class TestOnlineInCreation:
|
||||||
@@ -71,11 +71,11 @@ class TestOnlineInCreation:
|
|||||||
lp.sec("forward the message while still in creation")
|
lp.sec("forward the message while still in creation")
|
||||||
chat2 = ac1.create_group_chat("newgroup")
|
chat2 = ac1.create_group_chat("newgroup")
|
||||||
chat2.add_contact(ac2)
|
chat2.add_contact(ac2)
|
||||||
wait_msgs_changed(ac1, [(0, 0)]) # why not chat id?
|
ac1._evtracker.consume_events()
|
||||||
ac1.forward_messages([prepared_original], chat2)
|
ac1.forward_messages([prepared_original], chat2)
|
||||||
# XXX there might be two EVENT_MSGS_CHANGED and only one of them
|
# XXX there might be two EVENT_MSGS_CHANGED and only one of them
|
||||||
# is the one caused by forwarding
|
# is the one caused by forwarding
|
||||||
_, forwarded_id = wait_msgs_changed(ac1, [(chat2.id, None)])
|
forwarded_id = wait_msgs_changed(ac1, [(chat2.id, None)])
|
||||||
forwarded_msg = ac1.get_message_by_id(forwarded_id)
|
forwarded_msg = ac1.get_message_by_id(forwarded_id)
|
||||||
assert forwarded_msg.is_out_preparing()
|
assert forwarded_msg.is_out_preparing()
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ from datetime import datetime, timedelta, timezone
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import deltachat as dc
|
import deltachat as dc
|
||||||
from deltachat.capi import ffi, lib
|
|
||||||
from deltachat.cutil import iter_array
|
|
||||||
from deltachat.tracker import ImexFailed
|
from deltachat.tracker import ImexFailed
|
||||||
from deltachat import Account, account_hookimpl, Message
|
from deltachat import Account, account_hookimpl, Message
|
||||||
|
|
||||||
@@ -802,6 +800,7 @@ class TestOfflineChat:
|
|||||||
def test_audit_log_view_without_daymarker(self, ac1, lp):
|
def test_audit_log_view_without_daymarker(self, ac1, lp):
|
||||||
lp.sec("ac1: test audit log (show only system messages)")
|
lp.sec("ac1: test audit log (show only system messages)")
|
||||||
chat = ac1.create_group_chat(name="audit log sample data")
|
chat = ac1.create_group_chat(name="audit log sample data")
|
||||||
|
|
||||||
# promote chat
|
# promote chat
|
||||||
chat.send_text("hello")
|
chat.send_text("hello")
|
||||||
assert chat.is_promoted()
|
assert chat.is_promoted()
|
||||||
@@ -811,12 +810,6 @@ class TestOfflineChat:
|
|||||||
chat.set_name("audit log test group")
|
chat.set_name("audit log test group")
|
||||||
chat.send_text("a message in between")
|
chat.send_text("a message in between")
|
||||||
|
|
||||||
lp.sec("check message count of all messages")
|
|
||||||
assert len(chat.get_messages()) == 4
|
|
||||||
|
|
||||||
lp.sec("check message count of only system messages (without daymarkers)")
|
lp.sec("check message count of only system messages (without daymarkers)")
|
||||||
dc_array = ffi.gc(
|
sysmessages = [x for x in chat.get_messages() if x.is_system_message()]
|
||||||
lib.dc_get_chat_msgs(ac1._dc_context, chat.id, dc.const.DC_GCM_INFO_ONLY, 0),
|
assert len(sysmessages) == 3
|
||||||
lib.dc_array_unref,
|
|
||||||
)
|
|
||||||
assert len(list(iter_array(dc_array, lambda x: x))) == 2
|
|
||||||
|
|||||||
@@ -3145,6 +3145,13 @@ pub async fn create_group_chat(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !context.get_config_bool(Config::Bot).await?
|
||||||
|
&& !context.get_config_bool(Config::SkipStartMessages).await?
|
||||||
|
{
|
||||||
|
let text = stock_str::new_group_send_first_message(context).await;
|
||||||
|
add_info_msg(context, chat_id, &text, create_smeared_timestamp(context)).await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(chat_id)
|
Ok(chat_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,6 +266,10 @@ pub enum Config {
|
|||||||
/// True if it is a bot account.
|
/// True if it is a bot account.
|
||||||
Bot,
|
Bot,
|
||||||
|
|
||||||
|
/// True when to skip initial start messages in groups.
|
||||||
|
#[strum(props(default = "0"))]
|
||||||
|
SkipStartMessages,
|
||||||
|
|
||||||
/// Whether we send a warning if the password is wrong (set to false when we send a warning
|
/// Whether we send a warning if the password is wrong (set to false when we send a warning
|
||||||
/// because we do not want to send a second warning)
|
/// because we do not want to send a second warning)
|
||||||
#[strum(props(default = "0"))]
|
#[strum(props(default = "0"))]
|
||||||
|
|||||||
@@ -1315,6 +1315,7 @@ mod tests {
|
|||||||
"send_port",
|
"send_port",
|
||||||
"send_security",
|
"send_security",
|
||||||
"server_flags",
|
"server_flags",
|
||||||
|
"skip_start_messages",
|
||||||
"smtp_certificate_checks",
|
"smtp_certificate_checks",
|
||||||
"socks5_host",
|
"socks5_host",
|
||||||
"socks5_port",
|
"socks5_port",
|
||||||
|
|||||||
@@ -413,6 +413,9 @@ pub enum StockMessage {
|
|||||||
|
|
||||||
#[strum(props(fallback = "%1$s sent a message from another device."))]
|
#[strum(props(fallback = "%1$s sent a message from another device."))]
|
||||||
ChatProtectionDisabled = 171,
|
ChatProtectionDisabled = 171,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "Others will only see this group after you sent a first message."))]
|
||||||
|
NewGroupSendFirstMessage = 172,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StockMessage {
|
impl StockMessage {
|
||||||
@@ -1284,6 +1287,11 @@ pub(crate) async fn aeap_explanation_and_link(
|
|||||||
.replace2(new_addr)
|
.replace2(new_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stock string: `Others will only see this group after you sent a first message.`.
|
||||||
|
pub(crate) async fn new_group_send_first_message(context: &Context) -> String {
|
||||||
|
translated(context, StockMessage::NewGroupSendFirstMessage).await
|
||||||
|
}
|
||||||
|
|
||||||
/// Text to put in the [`Qr::Backup`] rendered SVG image.
|
/// Text to put in the [`Qr::Backup`] rendered SVG image.
|
||||||
///
|
///
|
||||||
/// The default is "Scan to set up second device for <account name (account addr)>". The
|
/// The default is "Scan to set up second device for <account name (account addr)>". The
|
||||||
|
|||||||
@@ -374,6 +374,10 @@ impl TestContext {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ctx.set_config(Config::SkipStartMessages, Some("1"))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
ctx,
|
ctx,
|
||||||
dir,
|
dir,
|
||||||
|
|||||||
Reference in New Issue
Block a user