Page MenuHomePhabricator

[SQLite] Query for latest edit in getLatestMessageEdit
AbandonedPublicDraft

Authored by ashoat on Jul 15 2024, 2:18 PM.

Details

Reviewers
kamil
tomek
marcin
Summary

This diff uses the new target_message index to query SQLite for all of the edits and reactions of a given message. We then swap in the text of the latest edit, similar to how the equivalent code in keyserver works.

Depends on D12761

Test Plan

I patched lib to make both native and web query for a specific message ID that I had edited, and confirmed that the latest edit appeared

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
2457–2460

Alternate approaches I considered:

  1. I spent 5min Googling and asking ChatGPT to see if I could access SQLite's internal JSON parsing library directly, but had no luck
  2. I considered including this in the original getMessageSQL, but all the options had some downsides:
    • We could query for it in getAllMessages too, but that seemed wasteful
    • We could try to match up the JSON-parsed field to the messages vector in a second pass after calling processMessagesResults, but that felt messy and seemed to defeat the purpose of factoring out the first pass
    • We could try to hack processMessagesResults so it passed extraneous data through into some miscellaneous field of MessageEntity, but that seemed messy too
  3. I looked into using folly::parseJson, but we'd have to add it to our WASM on web, which would bloat our bundle size
  4. I considered parsing the JSON with RegExp, but didn't love that idea

On second thought, there's really no good reason to do this parsing in C++... I could just return the whole list of related messages to JS, and let the parsing happen there. This would also make it the same SQLiteAPI reusable for @inka's work.

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 15 2024, 2:36 PM
Harbormaster failed remote builds in B30343: Diff 42305!

Abandoning for reason described above