Skip to content

Commit 386b91a

Browse files
committed
feat: stop saving txt_raw
It is redundant now that we have HTML view for long messages and is not updated when the message is edited.
1 parent d484720 commit 386b91a

File tree

6 files changed

+7
-42
lines changed

6 files changed

+7
-42
lines changed

deltachat-jsonrpc/src/api/types/message.rs

-3
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ pub struct MessageReadReceipt {
673673
#[derive(Serialize, TypeDef, schemars::JsonSchema)]
674674
#[serde(rename_all = "camelCase")]
675675
pub struct MessageInfo {
676-
rawtext: String,
677676
ephemeral_timer: EphemeralTimer,
678677
/// When message is ephemeral this contains the timestamp of the message expiry
679678
ephemeral_timestamp: Option<i64>,
@@ -686,7 +685,6 @@ pub struct MessageInfo {
686685
impl MessageInfo {
687686
pub async fn from_msg_id(context: &Context, msg_id: MsgId) -> Result<Self> {
688687
let message = Message::load_from_db(context, msg_id).await?;
689-
let rawtext = msg_id.rawtext(context).await?;
690688
let ephemeral_timer = message.get_ephemeral_timer().into();
691689
let ephemeral_timestamp = match message.get_ephemeral_timer() {
692690
deltachat::ephemeral::Timer::Disabled => None,
@@ -699,7 +697,6 @@ impl MessageInfo {
699697
let hop_info = msg_id.hop_info(context).await?;
700698

701699
Ok(Self {
702-
rawtext,
703700
ephemeral_timer,
704701
ephemeral_timestamp,
705702
error: message.error(),

src/chat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4415,7 +4415,7 @@ pub(crate) async fn save_copy_in_self_talk(
44154415
bail!("message already saved.");
44164416
}
44174417

4418-
let copy_fields = "from_id, to_id, timestamp_sent, timestamp_rcvd, type, txt, txt_raw, \
4418+
let copy_fields = "from_id, to_id, timestamp_sent, timestamp_rcvd, type, txt, \
44194419
mime_modified, mime_headers, mime_compressed, mime_in_reply_to, subject, msgrmsg";
44204420
let row_id = context
44214421
.sql

src/message.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::chat::{send_msg, Chat, ChatId, ChatIdBlocked, ChatVisibility};
1616
use crate::chatlist_events;
1717
use crate::config::Config;
1818
use crate::constants::{
19-
Blocked, Chattype, VideochatType, DC_CHAT_ID_TRASH, DC_DESIRED_TEXT_LEN, DC_MSG_ID_LAST_SPECIAL,
19+
Blocked, Chattype, VideochatType, DC_CHAT_ID_TRASH, DC_MSG_ID_LAST_SPECIAL,
2020
};
2121
use crate::contact::{self, Contact, ContactId};
2222
use crate::context::Context;
@@ -35,7 +35,7 @@ use crate::summary::Summary;
3535
use crate::sync::SyncData;
3636
use crate::tools::{
3737
buf_compress, buf_decompress, get_filebytes, get_filemeta, gm2local_offset, read_file,
38-
sanitize_filename, time, timestamp_to_str, truncate,
38+
sanitize_filename, time, timestamp_to_str,
3939
};
4040

4141
/// Message ID, including reserved IDs.
@@ -174,15 +174,6 @@ impl MsgId {
174174
self.0
175175
}
176176

177-
/// Returns raw text of a message, used for message info
178-
pub async fn rawtext(self, context: &Context) -> Result<String> {
179-
Ok(context
180-
.sql
181-
.query_get_value("SELECT txt_raw FROM msgs WHERE id=?", (self,))
182-
.await?
183-
.unwrap_or_default())
184-
}
185-
186177
/// Returns server foldernames and UIDs of a message, used for message info
187178
pub async fn get_info_server_urls(
188179
context: &Context,
@@ -219,12 +210,9 @@ impl MsgId {
219210
/// Returns detailed message information in a multi-line text form.
220211
pub async fn get_info(self, context: &Context) -> Result<String> {
221212
let msg = Message::load_from_db(context, self).await?;
222-
let rawtxt: String = self.rawtext(context).await?;
223213

224214
let mut ret = String::new();
225215

226-
let rawtxt = truncate(rawtxt.trim(), DC_DESIRED_TEXT_LEN);
227-
228216
let fts = timestamp_to_str(msg.get_timestamp());
229217
ret += &format!("Sent: {fts}");
230218

@@ -335,9 +323,6 @@ impl MsgId {
335323
if duration != 0 {
336324
ret += &format!("Duration: {duration} ms\n",);
337325
}
338-
if !rawtxt.is_empty() {
339-
ret += &format!("\n{rawtxt}\n");
340-
}
341326
if !msg.rfc724_mid.is_empty() {
342327
ret += &format!("\nMessage-ID: {}", msg.rfc724_mid);
343328

src/receive_imf.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,6 @@ async fn add_parts(
15391539
}
15401540
}
15411541

1542-
let mut txt_raw = "".to_string();
15431542
let (msg, typ): (&str, Viewtype) = if let Some(better_msg) = &better_msg {
15441543
if better_msg.is_empty() && is_partial_download.is_none() {
15451544
chat_id = DC_CHAT_ID_TRASH;
@@ -1554,11 +1553,6 @@ async fn add_parts(
15541553
save_mime_modified |= mime_parser.is_mime_modified && !part_is_empty && !hidden;
15551554
let save_mime_modified = save_mime_modified && parts.peek().is_none();
15561555

1557-
if part.typ == Viewtype::Text {
1558-
let msg_raw = part.msg_raw.as_ref().cloned().unwrap_or_default();
1559-
txt_raw = format!("{subject}\n\n{msg_raw}");
1560-
}
1561-
15621556
let ephemeral_timestamp = if in_fresh {
15631557
0
15641558
} else {
@@ -1585,7 +1579,7 @@ INSERT INTO msgs
15851579
rfc724_mid, chat_id,
15861580
from_id, to_id, timestamp, timestamp_sent,
15871581
timestamp_rcvd, type, state, msgrmsg,
1588-
txt, txt_normalized, subject, txt_raw, param, hidden,
1582+
txt, txt_normalized, subject, param, hidden,
15891583
bytes, mime_headers, mime_compressed, mime_in_reply_to,
15901584
mime_references, mime_modified, error, ephemeral_timer,
15911585
ephemeral_timestamp, download_state, hop_info
@@ -1594,7 +1588,7 @@ INSERT INTO msgs
15941588
?,
15951589
?, ?, ?, ?,
15961590
?, ?, ?, ?,
1597-
?, ?, ?, ?, ?,
1591+
?, ?, ?, ?,
15981592
?, ?, ?, ?, ?, 1,
15991593
?, ?, ?, ?,
16001594
?, ?, ?, ?
@@ -1604,7 +1598,7 @@ SET rfc724_mid=excluded.rfc724_mid, chat_id=excluded.chat_id,
16041598
from_id=excluded.from_id, to_id=excluded.to_id, timestamp_sent=excluded.timestamp_sent,
16051599
type=excluded.type, state=max(state,excluded.state), msgrmsg=excluded.msgrmsg,
16061600
txt=excluded.txt, txt_normalized=excluded.txt_normalized, subject=excluded.subject,
1607-
txt_raw=excluded.txt_raw, param=excluded.param,
1601+
param=excluded.param,
16081602
hidden=excluded.hidden,bytes=excluded.bytes, mime_headers=excluded.mime_headers,
16091603
mime_compressed=excluded.mime_compressed, mime_in_reply_to=excluded.mime_in_reply_to,
16101604
mime_references=excluded.mime_references, mime_modified=excluded.mime_modified, error=excluded.error, ephemeral_timer=excluded.ephemeral_timer,
@@ -1626,8 +1620,6 @@ RETURNING id
16261620
if trash || hidden { "" } else { msg },
16271621
if trash || hidden { None } else { message::normalize_text(msg) },
16281622
if trash || hidden { "" } else { &subject },
1629-
// txt_raw might contain invalid utf8
1630-
if trash || hidden { "" } else { &txt_raw },
16311623
if trash {
16321624
"".to_string()
16331625
} else {

src/sql/tables.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CREATE TABLE msgs (
6666
msgrmsg INTEGER DEFAULT 1,
6767
bytes INTEGER DEFAULT 0,
6868
txt TEXT DEFAULT '',
69-
txt_raw TEXT DEFAULT '',
69+
txt_raw TEXT DEFAULT '', -- deprecated 2025-03-29
7070
param TEXT DEFAULT '',
7171
starred INTEGER DEFAULT 0,
7272
timestamp_sent INTEGER DEFAULT 0,

src/tools/tools_tests.rs

-9
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ async fn test_parse_receive_headers_integration() {
4343
let raw = include_bytes!("../../test-data/message/mail_with_cc.txt");
4444
let expected = r"State: Fresh
4545
46-
hi
47-
4846
Message-ID: [email protected]
4947
5048
Hop: From: localhost; By: hq5.merlinux.eu; Date: Sat, 14 Sep 2019 17:00:22 +0000
@@ -56,13 +54,6 @@ DKIM Results: Passed=true";
5654
let raw = include_bytes!("../../test-data/message/encrypted_with_received_headers.eml");
5755
let expected = "State: Fresh, Encrypted
5856
59-
Re: Message from [email protected]
60-
61-
hi back\r\n\
62-
\r\n\
63-
-- \r\n\
64-
Sent with my Delta Chat Messenger: https://delta.chat
65-
6657
Message-ID: [email protected]
6758
6859
Hop: From: [127.0.0.1]; By: mail.example.org; Date: Mon, 27 Dec 2021 11:21:21 +0000

0 commit comments

Comments
 (0)