mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
Start making it possible to write to mailing lists (#2736)
See #748, #1964 and 3ba4c6718e/draft/mailing_list_managers.md
Also fix #2735: Assign outgoing messages from other devices to the mailing list
This commit is contained in:
15
src/chat.rs
15
src/chat.rs
@@ -225,10 +225,11 @@ impl ChatId {
|
||||
grpname: impl AsRef<str>,
|
||||
create_blocked: Blocked,
|
||||
create_protected: ProtectionStatus,
|
||||
param: Option<String>,
|
||||
) -> Result<Self> {
|
||||
let row_id =
|
||||
context.sql.insert(
|
||||
"INSERT INTO chats (type, name, grpid, blocked, created_timestamp, protected) VALUES(?, ?, ?, ?, ?, ?);",
|
||||
"INSERT INTO chats (type, name, grpid, blocked, created_timestamp, protected, param) VALUES(?, ?, ?, ?, ?, ?, ?);",
|
||||
paramsv![
|
||||
chattype,
|
||||
grpname.as_ref(),
|
||||
@@ -236,6 +237,7 @@ impl ChatId {
|
||||
create_blocked,
|
||||
dc_create_smeared_timestamp(context).await,
|
||||
create_protected,
|
||||
param.unwrap_or_default(),
|
||||
],
|
||||
).await?;
|
||||
|
||||
@@ -1061,11 +1063,12 @@ impl Chat {
|
||||
|
||||
/// Returns true if user can send messages to this chat.
|
||||
pub async fn can_send(&self, context: &Context) -> Result<bool> {
|
||||
Ok(!self.id.is_special()
|
||||
&& !self.is_device_talk()
|
||||
&& !self.is_mailing_list()
|
||||
&& !self.is_contact_request()
|
||||
&& self.is_self_in_chat(context).await?)
|
||||
let cannot_send = self.id.is_special()
|
||||
|| self.is_device_talk()
|
||||
|| self.is_contact_request()
|
||||
|| (self.is_mailing_list() && self.param.get(Param::ListPost).is_none_or_empty())
|
||||
|| !self.is_self_in_chat(context).await?;
|
||||
Ok(!cannot_send)
|
||||
}
|
||||
|
||||
/// Checks if the user is part of a chat
|
||||
|
||||
Reference in New Issue
Block a user