feat: allow to prepare WebXDC in draft for JSON-RPC - #8535
Draft
WofWca wants to merge 14 commits into
Draft
Conversation
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.
clippy test
factor out `have_draft_with_id`, simplify ID check
always assign msg.id
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODO:
I'd like to try a different approach. Submitting this for as journaling mostly.