Skip to content

feat: allow to prepare WebXDC in draft for JSON-RPC - #8535

Draft
WofWca wants to merge 14 commits into
mainfrom
wofwca/keep-draft-id-json-rpc
Draft

feat: allow to prepare WebXDC in draft for JSON-RPC#8535
WofWca wants to merge 14 commits into
mainfrom
wofwca/keep-draft-id-json-rpc

Conversation

@WofWca

@WofWca WofWca commented Aug 3, 2026

Copy link
Copy Markdown
Member

TODO:

  • See TODO comments.

I'd like to try a different approach. Submitting this for as journaling mostly.

WofWca added 14 commits July 29, 2026 16:00
Currently failing due to a bug.
Calling `send_msg()` with a draft message that was already sent
(by specifying `msg.id`)
would mutate that message in the DB and try to send it again.

Additionally, `prepare_msg_raw` now errors out
if the draft is not present in the database.
Previosuly the `UPDATE` query would simply update 0 rows
and we would proceed with trying to send a message
without having it in the `msgs` table.

The bug has been introduced in cf33db3
(#2887).

Semantically this makes `prepare_msg_raw` API less generic,
narrowing down its `update_msg_id` function only to drafts.
The "update draft" is anyway the only use case so far
for this parameter.
Thus this also removes the ability to specify an ID
that is different from `msg.id`, as was suggested in
#2887 (comment).
These IDs were always the same anyway.

Maybe it would make sense to, instead of returning an error
if the draft is already sent or does not exist,
simply upsert a new message without looking at `msg.id`,
as we would do with non-draft `msg.state`s,
but I wasn't sure how CFFI users (DC Android and DC iOS)
would take that.
So for now let's simply return an error instead of messing up the DB.
factor out `have_draft_with_id`, simplify ID check
The issue has been introduced in
cf33db3
(#2887).

This, again, has to do with a race where the draft message
is sent in another Future after `get_draft` but before `sql.execute`.

Related:
- 07fa9c3
  (#6052).
- df4fd82
  (#6061).
always assign msg.id in do_set_draft
Due to a gap between `get_draft_msg_id()` and `Message::load_from_db`.
Possibly can happen if the draft gets sent
while `get_draft()` is in progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant