mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
use separate column for device-msg-labels
This commit is contained in:
committed by
holger krekel
parent
b42d8799b4
commit
a9fe77b62e
17
src/chat.rs
17
src/chat.rs
@@ -1940,9 +1940,17 @@ pub fn add_device_msg_once(
|
|||||||
) -> Result<MsgId, Error> {
|
) -> Result<MsgId, Error> {
|
||||||
let (chat_id, _blocked) =
|
let (chat_id, _blocked) =
|
||||||
create_or_lookup_by_contact_id(context, DC_CONTACT_ID_DEVICE, Blocked::Not)?;
|
create_or_lookup_by_contact_id(context, DC_CONTACT_ID_DEVICE, Blocked::Not)?;
|
||||||
let rfc724_mid = format!("{}@device", label);
|
let rfc724_mid = dc_create_outgoing_rfc724_mid(None, "@device");
|
||||||
|
|
||||||
if let Ok((_, _, msg_id)) = message::rfc724_mid_exists(context, &rfc724_mid) {
|
// chat_id has an sql-index so it makes sense to add this although redundant
|
||||||
|
if let Ok(msg_id) = context.sql.query_row(
|
||||||
|
"SELECT id FROM msgs WHERE chat_id=? AND label=?",
|
||||||
|
params![chat_id, label],
|
||||||
|
|row| {
|
||||||
|
let msg_id: MsgId = row.get(0)?;
|
||||||
|
Ok(msg_id)
|
||||||
|
},
|
||||||
|
) {
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
"device-message {} already exist as {}", label, msg_id
|
"device-message {} already exist as {}", label, msg_id
|
||||||
@@ -1954,8 +1962,8 @@ pub fn add_device_msg_once(
|
|||||||
unarchive(context, chat_id)?;
|
unarchive(context, chat_id)?;
|
||||||
|
|
||||||
context.sql.execute(
|
context.sql.execute(
|
||||||
"INSERT INTO msgs (chat_id,from_id,to_id, timestamp,type,state, txt,param,rfc724_mid) \
|
"INSERT INTO msgs (chat_id,from_id,to_id, timestamp,type,state, txt,param,rfc724_mid,label) \
|
||||||
VALUES (?,?,?, ?,?,?, ?,?,?);",
|
VALUES (?,?,?, ?,?,?, ?,?,?,?);",
|
||||||
params![
|
params![
|
||||||
chat_id,
|
chat_id,
|
||||||
DC_CONTACT_ID_DEVICE,
|
DC_CONTACT_ID_DEVICE,
|
||||||
@@ -1966,6 +1974,7 @@ pub fn add_device_msg_once(
|
|||||||
msg.text.as_ref().map_or("", String::as_str),
|
msg.text.as_ref().map_or("", String::as_str),
|
||||||
msg.param.to_string(),
|
msg.param.to_string(),
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
|
label,
|
||||||
],
|
],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ fn do_initiate_key_transfer(context: &Context) -> Result<String> {
|
|||||||
// it would be too much noise to have two things popping up at the same time.
|
// it would be too much noise to have two things popping up at the same time.
|
||||||
// maybe_add_bcc_self_device_msg() is called on the other device
|
// maybe_add_bcc_self_device_msg() is called on the other device
|
||||||
// once the transfer is completed.
|
// once the transfer is completed.
|
||||||
|
maybe_add_bcc_self_device_msg(context)?;
|
||||||
Ok(setup_code)
|
Ok(setup_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
src/sql.rs
13
src/sql.rs
@@ -806,12 +806,19 @@ fn open(
|
|||||||
)?;
|
)?;
|
||||||
sql.set_raw_config_int(context, "dbversion", 55)?;
|
sql.set_raw_config_int(context, "dbversion", 55)?;
|
||||||
}
|
}
|
||||||
if dbversion < 56 {
|
if dbversion < 57 {
|
||||||
info!(context, "[migration] v56");
|
info!(context, "[migration] v57");
|
||||||
|
// label is a unique name and is currently used for device-messages only.
|
||||||
|
// in contrast to rfc724_mid and other fields, the label is generated on the device
|
||||||
|
// and allows reliable identifications this way.
|
||||||
|
sql.execute(
|
||||||
|
"ALTER TABLE msgs ADD COLUMN label TEXT DEFAULT '';",
|
||||||
|
params![],
|
||||||
|
)?;
|
||||||
if exists_before_update && sql.get_raw_config_int(context, "bcc_self").is_none() {
|
if exists_before_update && sql.get_raw_config_int(context, "bcc_self").is_none() {
|
||||||
sql.set_raw_config_int(context, "bcc_self", 1)?;
|
sql.set_raw_config_int(context, "bcc_self", 1)?;
|
||||||
}
|
}
|
||||||
sql.set_raw_config_int(context, "dbversion", 56)?;
|
sql.set_raw_config_int(context, "dbversion", 57)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (2) updates that require high-level objects
|
// (2) updates that require high-level objects
|
||||||
|
|||||||
Reference in New Issue
Block a user