mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 11:56:30 +03:00
refactor: remove Chattype::Undefined
This commit is contained in:
@@ -357,7 +357,7 @@ impl ChatId {
|
|||||||
let chat = Chat::load_from_db(context, self).await?;
|
let chat = Chat::load_from_db(context, self).await?;
|
||||||
|
|
||||||
match chat.typ {
|
match chat.typ {
|
||||||
Chattype::Undefined | Chattype::Broadcast => {
|
Chattype::Broadcast => {
|
||||||
bail!("Can't block chat of type {:?}", chat.typ)
|
bail!("Can't block chat of type {:?}", chat.typ)
|
||||||
}
|
}
|
||||||
Chattype::Single => {
|
Chattype::Single => {
|
||||||
@@ -398,7 +398,6 @@ impl ChatId {
|
|||||||
let chat = Chat::load_from_db(context, self).await?;
|
let chat = Chat::load_from_db(context, self).await?;
|
||||||
|
|
||||||
match chat.typ {
|
match chat.typ {
|
||||||
Chattype::Undefined => bail!("Can't accept chat of undefined chattype"),
|
|
||||||
Chattype::Single if chat.protected == ProtectionStatus::ProtectionBroken => {
|
Chattype::Single if chat.protected == ProtectionStatus::ProtectionBroken => {
|
||||||
// The chat was in the 'Request' state because the protection was broken.
|
// The chat was in the 'Request' state because the protection was broken.
|
||||||
// The user clicked 'Accept', so, now we want to set the status to Unprotected again:
|
// The user clicked 'Accept', so, now we want to set the status to Unprotected again:
|
||||||
@@ -459,7 +458,6 @@ impl ChatId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Chattype::Mailinglist => bail!("Cannot protect mailing lists"),
|
Chattype::Mailinglist => bail!("Cannot protect mailing lists"),
|
||||||
Chattype::Undefined => bail!("Undefined group type"),
|
|
||||||
},
|
},
|
||||||
ProtectionStatus::Unprotected | ProtectionStatus::ProtectionBroken => {}
|
ProtectionStatus::Unprotected | ProtectionStatus::ProtectionBroken => {}
|
||||||
};
|
};
|
||||||
@@ -1286,7 +1284,6 @@ impl Chat {
|
|||||||
match self.typ {
|
match self.typ {
|
||||||
Chattype::Single | Chattype::Broadcast | Chattype::Mailinglist => Ok(true),
|
Chattype::Single | Chattype::Broadcast | Chattype::Mailinglist => Ok(true),
|
||||||
Chattype::Group => is_contact_in_chat(context, self.id, ContactId::SELF).await,
|
Chattype::Group => is_contact_in_chat(context, self.id, ContactId::SELF).await,
|
||||||
Chattype::Undefined => Ok(false),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ impl Chatlist {
|
|||||||
.context("loading contact failed")?;
|
.context("loading contact failed")?;
|
||||||
(Some(lastmsg), Some(lastcontact))
|
(Some(lastmsg), Some(lastcontact))
|
||||||
}
|
}
|
||||||
Chattype::Single | Chattype::Undefined => (Some(lastmsg), None),
|
Chattype::Single => (Some(lastmsg), None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ pub const DC_CHAT_ID_LAST_SPECIAL: ChatId = ChatId::new(9);
|
|||||||
/// Chat type.
|
/// Chat type.
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
Default,
|
|
||||||
Display,
|
Display,
|
||||||
Clone,
|
Clone,
|
||||||
Copy,
|
Copy,
|
||||||
@@ -134,10 +133,6 @@ pub const DC_CHAT_ID_LAST_SPECIAL: ChatId = ChatId::new(9);
|
|||||||
)]
|
)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum Chattype {
|
pub enum Chattype {
|
||||||
/// Undefined chat type.
|
|
||||||
#[default]
|
|
||||||
Undefined = 0,
|
|
||||||
|
|
||||||
/// 1:1 chat.
|
/// 1:1 chat.
|
||||||
Single = 100,
|
Single = 100,
|
||||||
|
|
||||||
@@ -216,8 +211,6 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_chattype_values() {
|
fn test_chattype_values() {
|
||||||
// values may be written to disk and must not change
|
// values may be written to disk and must not change
|
||||||
assert_eq!(Chattype::Undefined, Chattype::default());
|
|
||||||
assert_eq!(Chattype::Undefined, Chattype::from_i32(0).unwrap());
|
|
||||||
assert_eq!(Chattype::Single, Chattype::from_i32(100).unwrap());
|
assert_eq!(Chattype::Single, Chattype::from_i32(100).unwrap());
|
||||||
assert_eq!(Chattype::Group, Chattype::from_i32(120).unwrap());
|
assert_eq!(Chattype::Group, Chattype::from_i32(120).unwrap());
|
||||||
assert_eq!(Chattype::Mailinglist, Chattype::from_i32(140).unwrap());
|
assert_eq!(Chattype::Mailinglist, Chattype::from_i32(140).unwrap());
|
||||||
|
|||||||
@@ -755,7 +755,7 @@ impl Message {
|
|||||||
Chattype::Group | Chattype::Broadcast | Chattype::Mailinglist => {
|
Chattype::Group | Chattype::Broadcast | Chattype::Mailinglist => {
|
||||||
Some(Contact::get_by_id(context, self.from_id).await?)
|
Some(Contact::get_by_id(context, self.from_id).await?)
|
||||||
}
|
}
|
||||||
Chattype::Single | Chattype::Undefined => None,
|
Chattype::Single => None,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -897,7 +897,6 @@ impl<'a> MimeFactory<'a> {
|
|||||||
let mut meta_part = None;
|
let mut meta_part = None;
|
||||||
|
|
||||||
let send_verified_headers = match chat.typ {
|
let send_verified_headers = match chat.typ {
|
||||||
Chattype::Undefined => bail!("Undefined chat type"),
|
|
||||||
// In single chats, the protection status isn't necessarily the same for both sides,
|
// In single chats, the protection status isn't necessarily the same for both sides,
|
||||||
// so we don't send the Chat-Verified header:
|
// so we don't send the Chat-Verified header:
|
||||||
Chattype::Single => false,
|
Chattype::Single => false,
|
||||||
|
|||||||
@@ -2182,7 +2182,7 @@ async fn ndn_maybe_add_info_msg(
|
|||||||
// If we get an NDN for the mailing list, just issue a warning.
|
// If we get an NDN for the mailing list, just issue a warning.
|
||||||
warn!(context, "ignoring NDN for mailing list.");
|
warn!(context, "ignoring NDN for mailing list.");
|
||||||
}
|
}
|
||||||
Chattype::Single | Chattype::Undefined => {}
|
Chattype::Single => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ impl Summary {
|
|||||||
.map(SummaryPrefix::Username)
|
.map(SummaryPrefix::Username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Chattype::Single | Chattype::Undefined => None,
|
Chattype::Single => None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user