mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
Do not store NULL values in msgs.autodelete_* columns
This commit is contained in:
@@ -883,8 +883,12 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get autodelete timer
|
// get autodelete timer
|
||||||
let autodelete_timer = Some(get_autodelete_timer(context, self.id)).filter(|&x| x != 0);
|
let autodelete_timer = get_autodelete_timer(context, self.id);
|
||||||
let autodelete_timestamp = autodelete_timer.map(|x| timestamp + i64::from(x));
|
let autodelete_timestamp = if autodelete_timer == 0 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
timestamp + i64::from(autodelete_timer)
|
||||||
|
};
|
||||||
|
|
||||||
// add message to the database
|
// add message to the database
|
||||||
|
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ pub struct Message {
|
|||||||
pub(crate) timestamp_sort: i64,
|
pub(crate) timestamp_sort: i64,
|
||||||
pub(crate) timestamp_sent: i64,
|
pub(crate) timestamp_sent: i64,
|
||||||
pub(crate) timestamp_rcvd: i64,
|
pub(crate) timestamp_rcvd: i64,
|
||||||
pub(crate) autodelete_timer: Option<i64>,
|
pub(crate) autodelete_timer: i64,
|
||||||
pub(crate) autodelete_timestamp: Option<i64>,
|
pub(crate) autodelete_timestamp: i64,
|
||||||
pub(crate) text: Option<String>,
|
pub(crate) text: Option<String>,
|
||||||
pub(crate) rfc724_mid: String,
|
pub(crate) rfc724_mid: String,
|
||||||
pub(crate) in_reply_to: Option<String>,
|
pub(crate) in_reply_to: Option<String>,
|
||||||
@@ -871,16 +871,14 @@ pub fn get_msg_info(context: &Context, msg_id: MsgId) -> String {
|
|||||||
ret += "\n";
|
ret += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(autodelete_timer) = msg.autodelete_timer {
|
if msg.autodelete_timer != 0 {
|
||||||
if autodelete_timer != 0 {
|
ret += &format!("Autodelete timer: {}\n", msg.autodelete_timer);
|
||||||
ret += &format!("Autodelete timer: {}\n", autodelete_timer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(autodelete_timestamp) = msg.autodelete_timestamp {
|
if msg.autodelete_timestamp != 0 {
|
||||||
ret += &format!(
|
ret += &format!(
|
||||||
"Expires: {}\n",
|
"Expires: {}\n",
|
||||||
dc_timestamp_to_str(autodelete_timestamp)
|
dc_timestamp_to_str(msg.autodelete_timestamp)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -916,7 +916,7 @@ fn open(
|
|||||||
// timer starts when message is read, so we want to have
|
// timer starts when message is read, so we want to have
|
||||||
// the value stored here until the timer starts.
|
// the value stored here until the timer starts.
|
||||||
sql.execute(
|
sql.execute(
|
||||||
"ALTER TABLE msgs ADD COLUMN autodelete_timer INTEGER;",
|
"ALTER TABLE msgs ADD COLUMN autodelete_timer INTEGER DEFAULT 0;",
|
||||||
NO_PARAMS,
|
NO_PARAMS,
|
||||||
)?;
|
)?;
|
||||||
// Timestamp indicating when the message should be
|
// Timestamp indicating when the message should be
|
||||||
@@ -924,7 +924,7 @@ fn open(
|
|||||||
// needs this value to display how much time is left until
|
// needs this value to display how much time is left until
|
||||||
// the message is deleted.
|
// the message is deleted.
|
||||||
sql.execute(
|
sql.execute(
|
||||||
"ALTER TABLE msgs ADD COLUMN autodelete_timestamp INTEGER;",
|
"ALTER TABLE msgs ADD COLUMN autodelete_timestamp INTEGER DEFAULT 0;",
|
||||||
NO_PARAMS,
|
NO_PARAMS,
|
||||||
)?;
|
)?;
|
||||||
sql.set_raw_config_int(context, "dbversion", 65)?;
|
sql.set_raw_config_int(context, "dbversion", 65)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user