Skip to content

Commit ca70fb9

Browse files
committed
feat: Get rid of MessageState::{OutPreparing,OutMdnRcvd} in the db
`OutPreparing` is deprecated since 2024-12-07, replace it with `OutFailed`, such messages are probably not interesting anymore. `OutMdnRcvd` is not used in the db for new messages since a30c6ae, `OutDelivered` is stored instead.
1 parent 045b586 commit ca70fb9

9 files changed

Lines changed: 21 additions & 64 deletions

File tree

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,8 +4003,6 @@ int dc_msg_get_viewtype (const dc_msg_t* msg);
40034003
* Marked as read on IMAP and MDN may be sent. Use dc_markseen_msgs() to mark messages as being seen.
40044004
*
40054005
* Outgoing message states:
4006-
* - @ref DC_STATE_OUT_PREPARING - For files which need time to be prepared before they can be sent,
4007-
* the message enters this state before @ref DC_STATE_OUT_PENDING. Deprecated.
40084006
* - @ref DC_STATE_OUT_DRAFT - Message saved as draft using dc_set_draft()
40094007
* - @ref DC_STATE_OUT_PENDING - The user has pressed the "send" button but the
40104008
* message is not yet sent and is pending in some way. Maybe we're offline (no checkmark).
@@ -5589,13 +5587,6 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
55895587
*/
55905588
#define DC_STATE_IN_SEEN 16
55915589

5592-
/**
5593-
* Outgoing message being prepared. See dc_msg_get_state() for details.
5594-
*
5595-
* @deprecated 2024-12-07
5596-
*/
5597-
#define DC_STATE_OUT_PREPARING 18
5598-
55995590
/**
56005591
* Outgoing message drafted. See dc_msg_get_state() for details.
56015592
*/

deltachat-ffi/src/lot.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ pub enum LotState {
230230
MsgInFresh = 10,
231231
MsgInNoticed = 13,
232232
MsgInSeen = 16,
233-
MsgOutPreparing = 18,
234233
MsgOutDraft = 19,
235234
MsgOutPending = 20,
236235
MsgOutFailed = 24,
@@ -246,7 +245,6 @@ impl From<MessageState> for LotState {
246245
InFresh => LotState::MsgInFresh,
247246
InNoticed => LotState::MsgInNoticed,
248247
InSeen => LotState::MsgInSeen,
249-
OutPreparing => LotState::MsgOutPreparing,
250248
OutDraft => LotState::MsgOutDraft,
251249
OutPending => LotState::MsgOutPending,
252250
OutFailed => LotState::MsgOutFailed,

deltachat-rpc-client/src/deltachat_rpc_client/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ class MessageState(IntEnum):
190190
IN_FRESH = 10
191191
IN_NOTICED = 13
192192
IN_SEEN = 16
193-
OUT_PREPARING = 18
194193
OUT_DRAFT = 19
195194
OUT_PENDING = 20
196195
OUT_FAILED = 24

python/src/deltachat/chat.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,6 @@ def send_msg(self, msg: Message) -> Message:
271271
sent out. This is the same object as was passed in, which
272272
has been modified with the new state of the core.
273273
"""
274-
if msg.is_out_preparing():
275-
assert msg.id != 0
276-
# get a fresh copy of dc_msg, the core needs it
277-
maybe_msg = Message.from_db(self.account, msg.id)
278-
if maybe_msg is not None:
279-
msg = maybe_msg
280-
else:
281-
raise ValueError("message does not exist")
282-
283274
sent_id = lib.dc_send_msg(self.account._dc_context, self.id, msg._dc_msg)
284275
if sent_id == 0:
285276
raise ValueError("message could not be sent")
@@ -333,26 +324,6 @@ def send_image(self, path):
333324
raise ValueError("message could not be sent")
334325
return Message.from_db(self.account, sent_id)
335326

336-
def send_prepared(self, message):
337-
"""send a previously prepared message.
338-
339-
:param message: a :class:`Message` instance previously returned by
340-
:meth:`prepare_file`.
341-
:raises ValueError: if message can not be sent.
342-
:returns: a :class:`deltachat.message.Message` instance as sent out.
343-
"""
344-
assert message.id != 0 and message.is_out_preparing()
345-
# get a fresh copy of dc_msg, the core needs it
346-
msg = Message.from_db(self.account, message.id)
347-
348-
# pass 0 as chat-id because core-docs say it's ok when out-preparing
349-
sent_id = lib.dc_send_msg(self.account._dc_context, 0, msg._dc_msg)
350-
if sent_id == 0:
351-
raise ValueError("message could not be sent")
352-
assert sent_id == msg.id
353-
# modify message in place to avoid bad state for the caller
354-
msg._dc_msg = Message.from_db(self.account, sent_id)._dc_msg
355-
356327
def set_draft(self, message):
357328
"""set message as draft.
358329

python/src/deltachat/message.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,12 @@ def is_in_seen(self):
351351
def is_outgoing(self):
352352
"""Return True if Message is outgoing."""
353353
return lib.dc_msg_get_state(self._dc_msg) in (
354-
const.DC_STATE_OUT_PREPARING,
355354
const.DC_STATE_OUT_PENDING,
356355
const.DC_STATE_OUT_FAILED,
357356
const.DC_STATE_OUT_MDN_RCVD,
358357
const.DC_STATE_OUT_DELIVERED,
359358
)
360359

361-
def is_out_preparing(self):
362-
"""Return True if Message is outgoing, but its file is being prepared."""
363-
return self._msgstate == const.DC_STATE_OUT_PREPARING
364-
365360
def is_out_pending(self):
366361
"""Return True if Message is outgoing, but is pending (no single checkmark)."""
367362
return self._msgstate == const.DC_STATE_OUT_PENDING

src/chat.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) ->
26132613
"chat_id cannot be a special chat: {chat_id}"
26142614
);
26152615

2616-
if msg.state != MessageState::Undefined && msg.state != MessageState::OutPreparing {
2616+
if msg.state != MessageState::Undefined {
26172617
msg.param.remove(Param::GuaranteeE2ee);
26182618
msg.param.remove(Param::ForcePlaintext);
26192619
// create_send_msg_jobs() will update `param` in the db.
@@ -2721,10 +2721,7 @@ async fn prepare_send_msg(
27212721
None
27222722
};
27232723

2724-
if matches!(
2725-
msg.state,
2726-
MessageState::Undefined | MessageState::OutPreparing
2727-
)
2724+
if msg.state == MessageState::Undefined
27282725
// Legacy SecureJoin "v*-request" messages are unencrypted.
27292726
&& msg.param.get_cmd() != SystemMessage::SecurejoinMessage
27302727
&& chat.is_encrypted(context).await?
@@ -2937,8 +2934,8 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
29372934
UPDATE msgs SET
29382935
timestamp=(
29392936
SELECT MAX(timestamp) FROM msgs INDEXED BY msgs_index7 WHERE
2940-
-- From `InFresh` to `OutMdnRcvd` inclusive except `OutDraft`.
2941-
state IN(10,13,16,18,20,24,26,28) AND
2937+
-- From `InFresh` to `OutDelivered` inclusive, except `OutDraft`.
2938+
state IN(10,13,16,18,20,24,26) AND
29422939
hidden IN(0,1) AND
29432940
chat_id=? AND
29442941
id<=?

src/message.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,13 +1381,8 @@ pub enum MessageState {
13811381
/// IMAP and MDN may be sent.
13821382
InSeen = 16,
13831383

1384-
/// For files which need time to be prepared before they can be
1385-
/// sent, the message enters this state before
1386-
/// OutPending.
1387-
///
1388-
/// Deprecated 2024-12-07.
1389-
OutPreparing = 18,
1390-
1384+
// Deprecated 2024-12-07. Removed 2026-04.
1385+
// OutPreparing = 18,
13911386
/// Message saved as draft.
13921387
OutDraft = 19,
13931388

@@ -1420,7 +1415,6 @@ impl std::fmt::Display for MessageState {
14201415
Self::InFresh => "Fresh",
14211416
Self::InNoticed => "Noticed",
14221417
Self::InSeen => "Seen",
1423-
Self::OutPreparing => "Preparing",
14241418
Self::OutDraft => "Draft",
14251419
Self::OutPending => "Pending",
14261420
Self::OutFailed => "Failed",
@@ -1437,7 +1431,7 @@ impl MessageState {
14371431
use MessageState::*;
14381432
matches!(
14391433
self,
1440-
OutPreparing | OutPending | OutDelivered | OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
1434+
OutPending | OutDelivered | OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
14411435
)
14421436
}
14431437

@@ -1446,7 +1440,7 @@ impl MessageState {
14461440
use MessageState::*;
14471441
matches!(
14481442
self,
1449-
OutPreparing | OutDraft | OutPending | OutFailed | OutDelivered | OutMdnRcvd
1443+
OutDraft | OutPending | OutFailed | OutDelivered | OutMdnRcvd
14501444
)
14511445
}
14521446

src/sql/migrations.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,18 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
23732373
.await?;
23742374
}
23752375

2376+
inc_and_check(&mut migration_version, 152)?;
2377+
if dbversion < migration_version {
2378+
sql.execute_migration(
2379+
"
2380+
UPDATE msgs SET state=26 WHERE state=28; -- Change OutMdnRcvd to OutDelivered.
2381+
UPDATE msgs SET state=19 WHERE state=24; -- Change OutPreparing to OutFailed.
2382+
",
2383+
migration_version,
2384+
)
2385+
.await?;
2386+
}
2387+
23762388
let new_version = sql
23772389
.get_raw_config_int(VERSION_CFG)
23782390
.await?

src/webxdc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl Context {
550550

551551
let send_now = !matches!(
552552
instance.state,
553-
MessageState::Undefined | MessageState::OutPreparing | MessageState::OutDraft
553+
MessageState::Undefined | MessageState::OutDraft
554554
);
555555

556556
status_update.uid = Some(create_id());

0 commit comments

Comments
 (0)